1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Collection of random (mainly) test improvements (#33733)

This commit is contained in:
Franck Nijhof
2020-04-06 12:51:48 +02:00
committed by GitHub
parent b31284b855
commit 98a2efcbab
33 changed files with 337 additions and 344 deletions

View File

@@ -167,8 +167,8 @@ async def test_intent_action_incomplete_v1(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert "" == await response.text()
assert response.status == 200
assert await response.text() == ""
async def test_intent_action_incomplete_v2(fixture):
@@ -180,8 +180,8 @@ async def test_intent_action_incomplete_v2(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert "" == await response.text()
assert response.status == 200
assert await response.text() == ""
async def test_intent_slot_filling_v1(fixture):
@@ -222,8 +222,8 @@ async def test_intent_slot_filling_v1(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert "" == await response.text()
assert response.status == 200
assert await response.text() == ""
async def test_intent_request_with_parameters_v1(fixture):
@@ -233,9 +233,9 @@ async def test_intent_request_with_parameters_v1(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("speech")
assert "You told us your sign is virgo." == text
assert text == "You told us your sign is virgo."
async def test_intent_request_with_parameters_v2(fixture):
@@ -245,9 +245,9 @@ async def test_intent_request_with_parameters_v2(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("fulfillmentText")
assert "You told us your sign is virgo." == text
assert text == "You told us your sign is virgo."
async def test_intent_request_with_parameters_but_empty_v1(fixture):
@@ -258,9 +258,9 @@ async def test_intent_request_with_parameters_but_empty_v1(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("speech")
assert "You told us your sign is ." == text
assert text == "You told us your sign is ."
async def test_intent_request_with_parameters_but_empty_v2(fixture):
@@ -271,9 +271,9 @@ async def test_intent_request_with_parameters_but_empty_v2(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("fulfillmentText")
assert "You told us your sign is ." == text
assert text == "You told us your sign is ."
async def test_intent_request_without_slots_v1(hass, fixture):
@@ -290,10 +290,10 @@ async def test_intent_request_without_slots_v1(hass, fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("speech")
assert "Anne Therese is at unknown and Paulus is at unknown" == text
assert text == "Anne Therese is at unknown and Paulus is at unknown"
hass.states.async_set("device_tracker.paulus", "home")
hass.states.async_set("device_tracker.anne_therese", "home")
@@ -301,9 +301,9 @@ async def test_intent_request_without_slots_v1(hass, fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("speech")
assert "You are both home, you silly" == text
assert text == "You are both home, you silly"
async def test_intent_request_without_slots_v2(hass, fixture):
@@ -320,10 +320,10 @@ async def test_intent_request_without_slots_v2(hass, fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("fulfillmentText")
assert "Anne Therese is at unknown and Paulus is at unknown" == text
assert text == "Anne Therese is at unknown and Paulus is at unknown"
hass.states.async_set("device_tracker.paulus", "home")
hass.states.async_set("device_tracker.anne_therese", "home")
@@ -331,9 +331,9 @@ async def test_intent_request_without_slots_v2(hass, fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("fulfillmentText")
assert "You are both home, you silly" == text
assert text == "You are both home, you silly"
async def test_intent_request_calling_service_v1(fixture, calls):
@@ -349,13 +349,13 @@ async def test_intent_request_calling_service_v1(fixture, calls):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert call_count + 1 == len(calls)
assert response.status == 200
assert len(calls) == call_count + 1
call = calls[-1]
assert "test" == call.domain
assert "dialogflow" == call.service
assert ["switch.test"] == call.data.get("entity_id")
assert "virgo" == call.data.get("hello")
assert call.domain == "test"
assert call.service == "dialogflow"
assert call.data.get("entity_id") == ["switch.test"]
assert call.data.get("hello") == "virgo"
async def test_intent_request_calling_service_v2(fixture, calls):
@@ -371,13 +371,13 @@ async def test_intent_request_calling_service_v2(fixture, calls):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert call_count + 1 == len(calls)
assert response.status == 200
assert len(calls) == call_count + 1
call = calls[-1]
assert "test" == call.domain
assert "dialogflow" == call.service
assert ["switch.test"] == call.data.get("entity_id")
assert "virgo" == call.data.get("hello")
assert call.domain == "test"
assert call.service == "dialogflow"
assert call.data.get("entity_id") == ["switch.test"]
assert call.data.get("hello") == "virgo"
async def test_intent_with_no_action_v1(fixture):
@@ -389,9 +389,9 @@ async def test_intent_with_no_action_v1(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("speech")
assert "You have not defined an action in your Dialogflow intent." == text
assert text == "You have not defined an action in your Dialogflow intent."
async def test_intent_with_no_action_v2(fixture):
@@ -403,9 +403,9 @@ async def test_intent_with_no_action_v2(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("fulfillmentText")
assert "You have not defined an action in your Dialogflow intent." == text
assert text == "You have not defined an action in your Dialogflow intent."
async def test_intent_with_unknown_action_v1(fixture):
@@ -416,9 +416,9 @@ async def test_intent_with_unknown_action_v1(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("speech")
assert "This intent is not yet configured within Home Assistant." == text
assert text == "This intent is not yet configured within Home Assistant."
async def test_intent_with_unknown_action_v2(fixture):
@@ -429,6 +429,6 @@ async def test_intent_with_unknown_action_v2(fixture):
response = await mock_client.post(
f"/api/webhook/{webhook_id}", data=json.dumps(data)
)
assert 200 == response.status
assert response.status == 200
text = (await response.json()).get("fulfillmentText")
assert "This intent is not yet configured within Home Assistant." == text
assert text == "This intent is not yet configured within Home Assistant."