-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·75 lines (67 loc) · 2.29 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!virtualenv/bin/python3
import json
import os
import time
import unittest
import alexa_metrolink_skill
class MetrolinkTest(unittest.TestCase):
@unittest.skip('slow test')
def test_all_stops_are_resolvable(self):
with open(os.path.join(os.path.dirname(__file__), 'stop-names.json')) as stop_names_file:
stop_names = json.load(stop_names_file).keys()
for stop_slug in stop_names:
time.sleep(1) # avoid rate limit
alexa_metrolink_skill.get_tram_stop_info(stop_slug)
def test_match(self):
self.assertEqual(
('Deansgate - Castlefield', 'deansgate-castlefield'),
alexa_metrolink_skill.match_tram_stop('Deansgate')
)
def test_simple(self):
print(alexa_metrolink_skill.handle_request({
"session": {
"new": False,
"sessionId": "SessionId.f5aa9e6b-19a5-477d-934c-f2eb54b60885",
"application": {
"applicationId": "amzn1.ask.skill.dummy"
},
"attributes": {},
"user": {
"userId": "amzn1.ask.account.dummy"
}
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.dummy",
"intent": {
"name": "TramTime",
"slots": {
"TramStop": {
"name": "TramStop",
"value": "new Islington"
}
}
},
"locale": "en-GB",
"timestamp": "2017-10-02T23:14:48Z"
},
"context": {
"AudioPlayer": {
"playerActivity": "IDLE"
},
"System": {
"application": {
"applicationId": "amzn1.ask.skill.dummy"
},
"user": {
"userId": "amzn1.ask.account.dummy"
},
"device": {
"supportedInterfaces": {}
}
}
},
"version": "1.0"
}, {}))
if __name__ == '__main__':
unittest.main()