-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTEST_test.py
More file actions
156 lines (139 loc) · 5.27 KB
/
TEST_test.py
File metadata and controls
156 lines (139 loc) · 5.27 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import json
import requests
#Get All Products List
def testapi1():
res = requests.get('https://automationexercise.com/api/productsList')
response_body = res.json()
assert response_body['responseCode'] == 200
#POST To All Products List
def testapi2():
res = requests.post('https://automationexercise.com/api/productsList')
response_body = res.json()
assert response_body['responseCode'] == 405
assert response_body.get('message') == 'This request method is not supported.'
#Get All Brands List
def testapi3():
res = requests.get("https://automationexercise.com/api/brandsList")
response_body = res.json()
assert response_body['responseCode'] == 200
# PUT To All Brands List
def testapi4():
res = requests.put('https://automationexercise.com/api/brandsList')
response_body = res.json()
assert response_body['responseCode'] == 405
assert response_body.get('message') == 'This request method is not supported.'
#POST To Search Product
def testapi5():
params = {
'search_product': 'Tops'
}
res = requests.post('https://automationexercise.com/api/searchProduct', data=params)
response_body = res.json()
assert response_body['responseCode'] == 200
#POST To Search Product without search_product parameter
def testapi6():
res = requests.post('https://automationexercise.com/api/searchProduct')
response_body = res.json()
assert response_body['responseCode'] == 400
assert response_body.get('message') == 'Bad request, search_product parameter is missing in POST request.'
#POST To Create User Account
def testapi11():
params = {
'name': 'Alex',
'email': 'alex@gmail.com',
'password': '12341234',
'title': 'Mr',
'birth_date': '19',
'birth_month': '10',
'birth_year': '1990',
'firstname': 'Alex',
'lastname': 'Longero',
'company': 'Awers',
'address1': 'Moka 3',
'address2': 'Loka 32',
'country': 'Estonia',
'zipcode': '13411',
'state': 'Harjumaa',
'city': 'Tallinn',
'mobile_number': '+37255657712'
}
res = requests.post('https://automationexercise.com/api/createAccount', data=params)
response_body = res.json()
assert response_body['responseCode'] == 201
assert response_body.get('message') == 'User created!'
#POST To Verify Login with valid details
def testapi7():
params = {'email': 'alex@gmail.com',
'password': '12341234'}
res = requests.post('https://automationexercise.com/api/verifyLogin', data=params)
resp_body = res.json()
assert resp_body['responseCode'] == 200
assert resp_body.get('message') == 'User exists!'
#POST To Verify Login without email parameter
def testapi8():
params = {'password': '12341234'}
res = requests.post('https://automationexercise.com/api/verifyLogin', data=params)
resp_body = res.json()
assert resp_body['responseCode'] == 400
assert resp_body.get('message') == 'Bad request, email or password parameter is missing in POST request.'
#DELETE To Verify Login
def testapi9():
res = requests.delete('https://automationexercise.com/api/verifyLogin')
resp_body = res.json()
assert resp_body['responseCode'] == 405
assert resp_body.get('message') == 'This request method is not supported.'
#POST To Verify Login with invalid details
def testapi10():
params = {
'email': 'alex@gmail.com',
'password': 'wrongpass111'
}
res = requests.post('https://automationexercise.com/api/verifyLogin', data = params)
response_body = res.json()
print(response_body)
assert response_body['responseCode'] == 404
assert response_body.get('message') == 'User not found!'
#PUT METHOD To Update User Account
def testapi13():
params = {
'name': 'Alex',
'email': 'alex@gmail.com',
'password': '12341234',
'title': 'Mr',
'birth_date': '19',
'birth_month': '10',
'birth_year': '1990',
'firstname': 'Alexandro',
'lastname': 'Longeroro',
'company': 'AwersOU',
'address1': 'Moka 3',
'address2': 'Loka 32',
'country': 'Estonia',
'zipcode': '13411',
'state': 'Harjumaa',
'city': 'Tallinn',
'mobile_number': '+37255657712'
}
res = requests.put('https://automationexercise.com/api/updateAccount', data=params)
response_body = res.json()
assert response_body['responseCode'] == 200
assert response_body.get('message') == 'User updated!'
#GET user account detail by email
def testapi14():
params = {
'email': 'alex@gmail.com'
}
res = requests.get('https://automationexercise.com/api/getUserDetailByEmail', params=params)
response_body = res.json()
print(response_body)
assert response_body['responseCode'] == 200
#DELETE METHOD To Delete User Account
def testapi12():
params = {
'email': 'alex@gmail.com',
'password': '12341234'
}
res = requests.delete('https://automationexercise.com/api/deleteAccount', data=params)
response_body = res.json()
assert response_body['responseCode'] == 200
assert response_body.get('message') == 'Account deleted!'