def check_id_value_in_json_response(context, id_attribute_name):
"""Check the ID attribute in the JSON response.
Check if ID is stored in a format like: '477e85660c504b698beae2b5f2a28b4e'
ie. it is a string with 32 characters containing 32 hexadecimal digits
"""
response = context.response
assert response is not None
json_data = response.json()
assert json_data is not None
check_attribute_presence(json_data, id_attribute_name)
id_attribute = json_data[id_attribute_name]
assert id_attribute is not None
assert isinstance(id_attribute, str) and len(id_attribute) == 32
assert all(char in string.hexdigits for char in id_attribute)
json_utils.py 文件源码
python
阅读 36
收藏 0
点赞 0
评论 0
评论列表
文章目录