Make State class immutable
This commit is contained in:
parent
70a528c04b
commit
b0948bef5f
6 changed files with 10 additions and 29 deletions
|
@ -267,18 +267,6 @@ class TestState(unittest.TestCase):
|
|||
{ATTR_FRIENDLY_NAME: name})
|
||||
self.assertEqual(name, state.name)
|
||||
|
||||
def test_copy(self):
|
||||
state = ha.State('domain.hello', 'world', {'some': 'attr'})
|
||||
# Patch dt_util.utcnow() so we know last_updated got copied too
|
||||
with patch('homeassistant.core.dt_util.utcnow',
|
||||
return_value=dt_util.utcnow() + timedelta(seconds=10)):
|
||||
copy = state.copy()
|
||||
self.assertEqual(state.entity_id, copy.entity_id)
|
||||
self.assertEqual(state.state, copy.state)
|
||||
self.assertEqual(state.attributes, copy.attributes)
|
||||
self.assertEqual(state.last_changed, copy.last_changed)
|
||||
self.assertEqual(state.last_updated, copy.last_updated)
|
||||
|
||||
def test_dict_conversion(self):
|
||||
state = ha.State('domain.hello', 'world', {'some': 'attr'})
|
||||
self.assertEqual(state, ha.State.from_dict(state.as_dict()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue