1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00
* 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
2018-07-29 01:53:37 +01:00
committed by Jason Hu
parent 867f80715e
commit c7f4bdafc0
16 changed files with 363 additions and 109 deletions

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):