1 | import unittest |
||
2 | from tube.tubeAPI import Tube |
||
3 | from tube.tubeAPI import TubeLine, TubeStation, TubeStationLinePlatform |
||
4 | from tube.tubeAPI import TubePlatform, TubeTrain |
||
5 | |||
6 | import vcr |
||
7 | |||
8 | my_vcr = vcr.VCR( |
||
9 | serializer = 'json', |
||
10 | cassette_library_dir = 'tube/tests/fixtures/cassettes', |
||
11 | record_mode = 'once', |
||
12 | ) |
||
13 | |||
14 | import logging |
||
15 | |||
16 | logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from vcrpy |
||
17 | vcr_log = logging.getLogger("vcr") |
||
18 | vcr_log.setLevel(logging.DEBUG) |
||
19 | |||
20 | class TestUserAPIAccess(unittest.TestCase): |
||
21 | def setUp(self): |
||
22 | self.tube = Tube() |
||
23 | |||
24 | View Code Duplication | def test_getAllTrainsForStation(self): |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
25 | with my_vcr.use_cassette('User-All-Station-KXX.json'): |
||
26 | trains = self.tube.getAllTrainsForStation("KXX") |
||
27 | self.assertIsInstance( trains, list ) |
||
28 | self.assertIsInstance( trains[0], TubeTrain ) |
||
29 | self.assertEqual( len(trains), 110 ) |
||
30 | with my_vcr.use_cassette('User-All-Station-KXX.json'): |
||
31 | kxx = self.tube.map.get(stationcode="KXX") |
||
32 | trains = self.tube.getAllTrainsForStation(kxx) |
||
33 | self.assertIsInstance( trains, list ) |
||
34 | self.assertIsInstance( trains[0], TubeTrain ) |
||
35 | self.assertEqual( len(trains), 110 ) |
||
36 | |||
37 | View Code Duplication | def test_getAllTrainsForLine(self): |
|
0 ignored issues
–
show
|
|||
38 | with my_vcr.use_cassette('User-All-Line-North.json'): |
||
39 | trains = self.tube.getAllTrainsForLine("N") |
||
40 | self.assertIsInstance( trains, list ) |
||
41 | self.assertIsInstance( trains[0], TubeTrain ) |
||
42 | self.assertEqual( len(trains), 152 ) |
||
43 | with my_vcr.use_cassette('User-All-Line-North.json'): |
||
44 | northern = self.tube.map.get(linecode="N") |
||
45 | trains = self.tube.getAllTrainsForLine(northern) |
||
46 | self.assertIsInstance( trains, list ) |
||
47 | self.assertIsInstance( trains[0], TubeTrain ) |
||
48 | self.assertEqual( len(trains), 152 ) |
||
49 |