mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Context (#15674)
* Add context * Add context to switch/light services * Test set_state API * Lint * Fix tests * Do not include context yet in comparison * Do not pass in loop * Fix Z-Wave tests * Add websocket test without user
This commit is contained in:
committed by
Jason Hu
parent
867f80715e
commit
c7f4bdafc0
@@ -277,6 +277,10 @@ class TestEvent(unittest.TestCase):
|
||||
'data': data,
|
||||
'origin': 'LOCAL',
|
||||
'time_fired': now,
|
||||
'context': {
|
||||
'id': event.context.id,
|
||||
'user_id': event.context.user_id,
|
||||
},
|
||||
}
|
||||
self.assertEqual(expected, event.as_dict())
|
||||
|
||||
@@ -598,18 +602,16 @@ class TestStateMachine(unittest.TestCase):
|
||||
self.assertEqual(1, len(events))
|
||||
|
||||
|
||||
class TestServiceCall(unittest.TestCase):
|
||||
"""Test ServiceCall class."""
|
||||
def test_service_call_repr():
|
||||
"""Test ServiceCall repr."""
|
||||
call = ha.ServiceCall('homeassistant', 'start')
|
||||
assert str(call) == \
|
||||
"<ServiceCall homeassistant.start (c:{})>".format(call.context.id)
|
||||
|
||||
def test_repr(self):
|
||||
"""Test repr method."""
|
||||
self.assertEqual(
|
||||
"<ServiceCall homeassistant.start>",
|
||||
str(ha.ServiceCall('homeassistant', 'start')))
|
||||
|
||||
self.assertEqual(
|
||||
"<ServiceCall homeassistant.start: fast=yes>",
|
||||
str(ha.ServiceCall('homeassistant', 'start', {"fast": "yes"})))
|
||||
call2 = ha.ServiceCall('homeassistant', 'start', {'fast': 'yes'})
|
||||
assert str(call2) == \
|
||||
"<ServiceCall homeassistant.start (c:{}): fast=yes>".format(
|
||||
call2.context.id)
|
||||
|
||||
|
||||
class TestServiceRegistry(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user