-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_post.py
46 lines (38 loc) · 1.83 KB
/
test_post.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
import requests
def get_token():
url = 'https://api.discovery-staging.verifiable.com/auth/token/password'
headers = {'content-type': 'application/json'}
data = {"email": "[email protected]", "password": "sasa"}
req = requests.post(url, headers=headers, json=data)
return req.text
def test_licence_found():
pre_token = get_token()
token_id = pre_token.split('"')[3]
token = pre_token.split('"')[7]
found = "https://api.discovery-staging.verifiable.com/providers/{providerId}/licenses/{id}"
hed = {'Authorization': 'Bearer ' + token}
result = requests.get(found, headers=hed).json()
print("Found")
assert result["licenseNumber"] == "8"
def test_licence_not_found():
pre_token = get_token()
token_id = pre_token.split('"')[3]
token = pre_token.split('"')[7]
not_found = "https://api.discovery-staging.verifiable.com/providers/{providerId}/licenses/{id}"
hed = {'Authorization': 'Bearer ' + token}
result = requests.get(not_found, headers=hed).json()
print("Not Found")
assert result['status'] == 404
def test_multi_status():
pre_token = get_token()
token_id = pre_token.split('"')[3]
token = pre_token.split('"')[7]
url = "https://api.discovery-staging.verifiable.com/providers/{providerId}/licenses"
hed = {'Authorization': 'Bearer ' + token}
result = requests.get(url, headers=hed).json()
status_found = [data for data in result if data['currentVerificationStatus'] == 'Found']
status_not_found = [data for data in result if data['currentVerificationStatus'] == 'NotFound']
status_needs_review = [data for data in result if data['currentVerificationStatus'] == 'NeedsReview']
print(f'{len(status_found)} in Found status')
print(f'{len(status_not_found)} in Not Found status')
print(f'{len(status_needs_review)} in NeedsReview status')