in src/test-client/app.py [0:0]
def create_payload(image_path:PathLike=None, user_id:str=None, properties:Mapping[str,str]=None, idcard:PathLike=None)->dict:
'''
Creates a valid payload for testing.
'''
if user_id is None:
user_id = str(randint(10000000,100000000-1))
if properties is None:
properties = {
'age' : str(randint(1,80)),
'fname': names.get_first_name(),
'lname': names.get_last_name()
}
payload = {
'UserId': user_id,
#'Image': str(b64encode(photo_contents),'utf-8'),
'Properties': properties
}
if image_path is not None:
with open(image_path,'rb') as f:
photo_contents = f.read()
payload['Image'] = str(b64encode(photo_contents),'utf-8')
if idcard is not None:
with open(image_path,'rb') as f:
photo_contents = f.read()
payload['IdCard'] = str(b64encode(photo_contents),'utf-8')
return payload