-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.py
34 lines (25 loc) · 919 Bytes
/
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
import unittest
import config
from api.api import TransAPI
from api.proxy import FileProxyManager
from config import EXAMPLE_RESULT_FILE
from models import Stop
class TestDataValidation(unittest.TestCase):
def setUp(self):
with open(EXAMPLE_RESULT_FILE, "r") as f:
self.example_result = f.read()
def test_validation(self):
stop = Stop.parse_raw(self.example_result)
print(stop)
self.assertIsNotNone(stop.route_path)
class TestAPIGetStation(unittest.TestCase):
def setUp(self) -> None:
self.api = TransAPI()
def test_get_station(self, api=None):
api = api or self.api
station = api.get_station_info(1, 1)
self.assertEqual(type(station), dict)
stop = Stop.parse_obj(station)
def test_proxy(self):
api = TransAPI(FileProxyManager(file_name=config.PROXIES_FILE))
self.test_get_station(api=api)