def test_chain_with_different_for_the_nth_time_error(server: FakeServer):
requests.patch(server.base_uri + "/users", json={"name": "new_name", "level": 5})
requests.patch(server.base_uri + "/users", json={"name": "new_name", "level": 6})
requests.patch(server.base_uri + "/users", json={"name": "new_name", "level": 7})
with pytest.raises(AssertionError) as error:
expect_that(server.was_requested("patch", "/users").
for_the_first_time().
with_content_type("application/json").
with_body('{"name": "new_name", "level": 6}').
for_the_second_time().
with_content_type("application/json").
with_body('{"name": "new_name", "level": 7}').
for_the_3_time().
with_content_type("application/json").
with_body('{"name": "new_name", "level": 8}'))
assert str(error.value) == ("Expect that server was requested with [PATCH] http://localhost:8081/users.\n"
"For the 1 time: with body '{\"name\": \"new_name\", \"level\": 6}'.\n"
"But for the 1 time: body was '{\"name\": \"new_name\", \"level\": 5}'.\n"
"For the 2 time: with body '{\"name\": \"new_name\", \"level\": 7}'.\n"
"But for the 2 time: body was '{\"name\": \"new_name\", \"level\": 6}'.\n"
"For the 3 time: with body '{\"name\": \"new_name\", \"level\": 8}'.\n"
"But for the 3 time: body was '{\"name\": \"new_name\", \"level\": 7}'.")
test_fake_server_expectations.py 文件源码
python
阅读 38
收藏 0
点赞 0
评论 0
评论列表
文章目录