forked from cita-bot/cita-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
49 lines (40 loc) · 1.68 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
import logging
import os
import unittest
from bcncita import CustomerProfile, DocType, Office, OperationType, Province, try_cita
class TestBot(unittest.TestCase):
def test_cita(self):
params = {
"chrome_driver_path": "chromedriver",
"auto_office": True,
"auto_captcha": True,
"name": "BORIS JOHNSON",
"doc_type": DocType.PASSPORT,
"doc_value": "132435465",
"phone": "600000000",
"email": "[email protected]",
}
customer = CustomerProfile(
**params,
province=Province.BARCELONA,
operation_code=OperationType.BREXIT,
offices=[Office.BARCELONA],
)
with self.assertLogs(None, level=logging.INFO) as logs:
try_cita(context=customer, cycles=1)
self.assertIn("INFO:root:\x1b[33m[Attempt 1/1]\x1b[0m", logs.output)
self.assertIn("INFO:root:[Step 1/6] Personal info", logs.output)
self.assertIn("INFO:root:[Step 2/6] Office selection", logs.output)
self.assertIn("INFO:root:[Step 3/6] Contact info", logs.output)
self.assertIn("INFO:root:[Step 4/6] Cita attempt -> selection hit!", logs.output)
for province in Province:
customer = CustomerProfile(
**params, province=province, operation_code=OperationType.TOMA_HUELLAS,
)
with self.assertLogs(None, level=logging.INFO) as logs:
try_cita(context=customer, cycles=1)
self.assertIn("INFO:root:Instructions page loaded", logs.output)
if __name__ == "__main__":
if not os.environ.get("CITA_TEST"):
os._exit(0)
unittest.main()