forked from cita-bot/cita-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
65 lines (56 loc) · 1.95 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
import logging
import os
import unittest
from bcncita import (
CustomerProfile,
DocType,
Office,
OperationType,
Province,
init_wedriver,
start_with,
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)
driver = init_wedriver(customer)
for province in Province:
customer = CustomerProfile(
**params,
province=province,
operation_code=OperationType.TOMA_HUELLAS,
)
with self.assertLogs(None, level=logging.INFO) as logs:
start_with(driver=driver, context=customer, cycles=1)
self.assertIn(
"INFO:root:Instructions page loaded",
logs.output,
msg=f"Can't load instructions for province={province}",
)
if __name__ == "__main__":
if not os.environ.get("CITA_TEST"):
os._exit(0)
unittest.main()