Skip to content

Commit

Permalink
Add all test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Feb 8, 2023
1 parent 1716024 commit bad3871
Showing 1 changed file with 135 additions and 5 deletions.
140 changes: 135 additions & 5 deletions tests/components/alexa/test_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ def mock_service(call):
"text": "You told us your sign is {{ ZodiacSign }}.",
}
},
"GetZodiacHoroscopeIDIntent": {
"speech": {
"type": "plain",
"text": "You told us your sign is {{ ZodiacSign_ID }}.",
}
},
"GetZodiacHoroscopeNearestValueIntent": {
"speech": {
"type": "plain",
"text": "You told us your sign is {{ ZodiacSign_NEAREST }}.",
}
},
"GetZodiacHoroscopeNearestIDIntent": {
"speech": {
"type": "plain",
"text": "You told us your sign is {{ ZodiacSign_NEAREST_ID }}.",
}
},
"AMAZON.PlaybackAction<object@MusicCreativeWork>": {
"speech": {
"type": "plain",
Expand Down Expand Up @@ -301,7 +319,7 @@ async def test_intent_request_with_slots_and_synonym_resolution(alexa_client):


async def test_intent_request_with_slots_and_synonym_id_resolution(alexa_client):
"""Test a request with slots and a name synonym."""
"""Test a request with slots, id and a name synonym."""
data = {
"version": "1.0",
"session": {
Expand All @@ -322,20 +340,75 @@ async def test_intent_request_with_slots_and_synonym_id_resolution(alexa_client)
"requestId": REQUEST_ID,
"timestamp": "2015-05-13T12:34:56Z",
"intent": {
"name": "GetZodiacHoroscopeIntent",
"name": "GetZodiacHoroscopeIDIntent",
"slots": {
"ZodiacSign": {
"name": "ZodiacSign",
"value": "V zodiac",
"resolutions": {
"resolutionsPerAuthority": [
{
"authority": AUTHORITY_ID,
"status": {"code": "ER_SUCCESS_MATCH"},
"values": [{"value": {"name": "Virgo", "id": "1"}}],
}
]
},
}
},
},
},
}
req = await _intent_req(alexa_client, data)
assert req.status == HTTPStatus.OK
data = await req.json()
text = data.get("response", {}).get("outputSpeech", {}).get("text")
assert text == "You told us your sign is 1."


async def test_intent_request_with_slots_and_multi_synonym_nearest_value_resolution(
alexa_client,
):
"""Test a request with slots and multiple name synonyms (nearest value)."""
data = {
"version": "1.0",
"session": {
"new": False,
"sessionId": SESSION_ID,
"application": {"applicationId": APPLICATION_ID},
"attributes": {
"supportedHoroscopePeriods": {
"daily": True,
"weekly": False,
"monthly": False,
}
},
"user": {"userId": "amzn1.account.AM3B00000000000000000000000"},
},
"request": {
"type": "IntentRequest",
"requestId": REQUEST_ID,
"timestamp": "2015-05-13T12:34:56Z",
"intent": {
"name": "GetZodiacHoroscopeNearestValueIntent",
"slots": {
"ZodiacSign": {
"name": "ZodiacSign",
"value": "Virgio Test",
"resolutions": {
"resolutionsPerAuthority": [
{
"authority": AUTHORITY_ID,
"status": {"code": "ER_SUCCESS_MATCH"},
"values": [
{"value": {"name": "Virgo", "id": "VIRGO"}}
{"value": {"name": "Virgio Test", "id": "2"}}
],
}
},
{
"authority": AUTHORITY_ID,
"status": {"code": "ER_SUCCESS_MATCH"},
"values": [{"value": {"name": "Virgo", "id": "1"}}],
},
]
},
}
Expand All @@ -347,7 +420,64 @@ async def test_intent_request_with_slots_and_synonym_id_resolution(alexa_client)
assert req.status == HTTPStatus.OK
data = await req.json()
text = data.get("response", {}).get("outputSpeech", {}).get("text")
assert text == "You told us your sign is Virgo."
assert text == "You told us your sign is Virgio Test."


async def test_intent_request_with_slots_and_multi_synonym_nearest_id_resolution(
alexa_client,
):
"""Test a request with slots and multiple name synonyms (nearest id)."""
data = {
"version": "1.0",
"session": {
"new": False,
"sessionId": SESSION_ID,
"application": {"applicationId": APPLICATION_ID},
"attributes": {
"supportedHoroscopePeriods": {
"daily": True,
"weekly": False,
"monthly": False,
}
},
"user": {"userId": "amzn1.account.AM3B00000000000000000000000"},
},
"request": {
"type": "IntentRequest",
"requestId": REQUEST_ID,
"timestamp": "2015-05-13T12:34:56Z",
"intent": {
"name": "GetZodiacHoroscopeNearestIDIntent",
"slots": {
"ZodiacSign": {
"name": "ZodiacSign",
"value": "Virgio Test",
"resolutions": {
"resolutionsPerAuthority": [
{
"authority": AUTHORITY_ID,
"status": {"code": "ER_SUCCESS_MATCH"},
"values": [
{"value": {"name": "Virgio Test", "id": "2"}}
],
},
{
"authority": AUTHORITY_ID,
"status": {"code": "ER_SUCCESS_MATCH"},
"values": [{"value": {"name": "Virgo", "id": "1"}}],
},
]
},
}
},
},
},
}
req = await _intent_req(alexa_client, data)
assert req.status == HTTPStatus.OK
data = await req.json()
text = data.get("response", {}).get("outputSpeech", {}).get("text")
assert text == "You told us your sign is 2."


async def test_intent_request_with_slots_and_multi_synonym_resolution(alexa_client):
Expand Down

0 comments on commit bad3871

Please sign in to comment.