Skip to content

Commit

Permalink
Fixed assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
chmielowiec committed May 23, 2020
1 parent e2f56bd commit 73c4c40
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions tests/helpers/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,14 @@ async def test_call_with_required_features(hass, mock_entities):
ha.ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
required_features=[SUPPORT_A],
)
assert len(mock_entities) == 4
# Called once because only one of the entities had the required features

assert test_service_mock.call_count == 2
expected = [
mock_entities["light.kitchen"],
mock_entities["light.bedroom"],
]
actual = [call[0][0] for call in test_service_mock.call_args_list]
assert all(entity in actual for entity in expected)


async def test_call_with_both_required_features(hass, mock_entities):
Expand All @@ -349,9 +354,11 @@ async def test_call_with_both_required_features(hass, mock_entities):
ha.ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
required_features=[SUPPORT_A | SUPPORT_B],
)
assert len(mock_entities) == 4
# Called once because only one of the entities had the required features

assert test_service_mock.call_count == 1
assert [call[0][0] for call in test_service_mock.call_args_list] == [
mock_entities["light.bedroom"]
]


async def test_call_with_one_of_required_features(hass, mock_entities):
Expand All @@ -364,9 +371,15 @@ async def test_call_with_one_of_required_features(hass, mock_entities):
ha.ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
required_features=[SUPPORT_A, SUPPORT_C],
)
assert len(mock_entities) == 4
# Called once because only one of the entities had the required features

assert test_service_mock.call_count == 3
expected = [
mock_entities["light.kitchen"],
mock_entities["light.bedroom"],
mock_entities["light.bathroom"],
]
actual = [call[0][0] for call in test_service_mock.call_args_list]
assert all(entity in actual for entity in expected)


async def test_call_with_sync_func(hass, mock_entities):
Expand Down

0 comments on commit 73c4c40

Please sign in to comment.