Allow chaining contexts (#21028)

* Allow chaining contexts

* Add stubbed out migration
This commit is contained in:
Paulus Schoutsen 2019-03-01 10:08:38 -08:00 committed by GitHub
parent b39846fb6b
commit 52f337ef00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 88 additions and 39 deletions

View file

@ -310,6 +310,7 @@ class TestEvent(unittest.TestCase):
'time_fired': now,
'context': {
'id': event.context.id,
'parent_id': None,
'user_id': event.context.user_id,
},
}
@ -1076,3 +1077,16 @@ async def test_service_call_event_contains_original_data(hass):
assert len(calls) == 1
assert calls[0].data['number'] == 23
assert calls[0].context is context
def test_context():
"""Test context init."""
c = ha.Context()
assert c.user_id is None
assert c.parent_id is None
assert c.id is not None
c = ha.Context(23, 100)
assert c.user_id == 23
assert c.parent_id == 100
assert c.id is not None