testing
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
{
|
||||
"access_token": "bftc1ostvp3fucj9sxzkdgonnhcoi9uuqq2da93m",
|
||||
"date_joined": "2022-10-04 00:46:37",
|
||||
"email": "lpm0073@gmail.com",
|
||||
"expires_in": 3600,
|
||||
"first_name": "Lawrence",
|
||||
"fullname": "Lawrence McDaniel",
|
||||
"id": 6,
|
||||
|
48
data/tests.py
Normal file
48
data/tests.py
Normal file
@ -0,0 +1,48 @@
|
||||
import json
|
||||
|
||||
# Opening JSON file
|
||||
f = open('get_user_details_extended.json')
|
||||
|
||||
# returns JSON object as
|
||||
# a dictionary
|
||||
response = json.load(f)
|
||||
|
||||
def is_valid_user_details(response) -> bool:
|
||||
"""
|
||||
validate that the object passed is a dict containing at least the keys
|
||||
in qc_keys.
|
||||
"""
|
||||
qc_keys = [
|
||||
"id",
|
||||
"date_joined",
|
||||
"email",
|
||||
"first_name",
|
||||
"fullname",
|
||||
"is_staff",
|
||||
"is_superuser",
|
||||
"last_name",
|
||||
"username",
|
||||
]
|
||||
if all(key in response for key in qc_keys):
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_wp_oauth_refresh_token_response(response) -> bool:
|
||||
"""
|
||||
validate that the structure of the response contains the keys of
|
||||
a refresh token dict.
|
||||
"""
|
||||
if not is_valid_user_details(response):
|
||||
return False
|
||||
qc_keys = ["access_token", "expires_in", "refresh_token", "scope", "token_type"]
|
||||
if all(key in response for key in qc_keys):
|
||||
return True
|
||||
return False
|
||||
|
||||
print('is_valid_user_details')
|
||||
print(is_valid_user_details(response))
|
||||
|
||||
print('is_wp_oauth_refresh_token_response')
|
||||
print(is_wp_oauth_refresh_token_response(response))
|
||||
|
||||
|
Reference in New Issue
Block a user