* 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:
Paulus Schoutsen authored and Jason Hu committed 2018-07-28 17:53:37 -07:00
1 parent 867f80715e
commit c7f4bdafc0
16 files changed
+363 -109

No files matched your search

+13 -11
View File
@@ -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):