-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_scrappy.py
40 lines (31 loc) · 1.2 KB
/
test_scrappy.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
import scrappy as sp
class test_scrappy:
"""
contains test suite to test scrappy.
"""
def __init__(self,pnames):
self.pnames = pnames
def test_status(self):
"""
Checks for the status codes after making an request.If tests fails prints the failing website name with the status code.
"""
for p in self.pnames:
prod = sp.Product(p)
status_codes = sp.Request(prod).make_request()["status"]
tcount = 1;
for stat in status_codes:
if (status_codes[stat] != 200):
print(f"Test case {tcount} Failed.")
print(f" {stat} responded with {status_codes[stat]} status.")
break;
else:
print(f"Test case {tcount} passed.")
tcount+=1
print(f"Tests Done for Product {p}.")
print()
print("Automated testing done.")
# driver code.
if __name__ == "__main__":
pnames = ["iphone 13","samsung s23","woben water bottle","redmi 12 5g","one plus 9r","sony headphones","poco m6 pro 5g"]
tc1 = test_scrappy(pnames)
tc1.test_status()