-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_07_put_contact.py
50 lines (33 loc) · 1.55 KB
/
test_07_put_contact.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
from base import Base
class TestPutContact(Base):
def test_Put_contact(self):
# Get Bearer token
if not self.token:
self.create_user()
self.get_token()
assert self.token
self.create_contact(self.creds_file['contacts'][0])
# Get Contact id
response_code, response = self.get_contacts()
# Verify that contact id is receieved
assert response_code == 200
contact_id = response[0]['_id']
# Call to update contact using "PUT" method with single entity in body
response_code, response = self.update_contact("PUT", contact_id)
# Verify that API call get's failed if not passed all the entity in "PUT" method
assert response_code == 400
# Call to update contact using "PUT" menthod
response_code, response = self.update_contact("PUT", contact_id, self.creds_file['Update_contact'])
# Veirfy that API call was successful
assert response_code == 200
# Verify that correct record was updated
assert response["_id"] == contact_id
# Call to get updated contact
response_code, response = self.get_contact(contact_id)
# Verify that api call was successful
assert response_code == 200
# Verify that correct contact was retrived
assert response["_id"] == contact_id
# Verify that all the enetites are updated
for key in self.creds_file['Update_contact']:
assert response[key] == self.creds_file['Update_contact'][key]