test_pet_api.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:lepo 作者: akx 项目源码 文件源码
def test_post_pet(client, api_urls, with_tag):
    payload = {
        'name': get_random_string(),
    }
    if with_tag:
        payload['tag'] = get_random_string()

    pet = get_data_from_response(
        client.post(
            '/api/pets',
            json.dumps(payload),
            content_type='application/json'
        )
    )
    assert pet['name'] == payload['name']
    assert pet['id']
    if with_tag:
        assert pet['tag'] == payload['tag']

    # Test we can get the pet from the API now
    assert get_data_from_response(client.get('/api/pets')) == [pet]
    assert get_data_from_response(client.get('/api/pets/{}'.format(pet['id']))) == pet
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号