RED: test for message and status_code
This commit is contained in:
parent
2a02a839b7
commit
c058c7513c
|
@ -125,6 +125,66 @@ class ApiTestCase(unittest.TestCase):
|
|||
== be_the_fun_in_de_funes[attribute_name]
|
||||
)
|
||||
|
||||
def test_payload_content_bad_format_status_code(self):
|
||||
be_the_fun_in_de_funes = {
|
||||
"id": 1,
|
||||
"title": "La Grande Vadrouille",
|
||||
"description": "During World War II, two French civilians and a downed English Bomber Crew set "
|
||||
"out from Paris to cross the demarcation line between Nazi-occupied Northern France and the "
|
||||
"South. From there they will be able to escape to England. First, they must avoid German troops -"
|
||||
"and the consequences of their own blunders.",
|
||||
"genres": ["Comedy", "War"],
|
||||
"release_date": "1966-12-07",
|
||||
"vote_average": 7.7,
|
||||
"vote_count": 1123,
|
||||
}
|
||||
|
||||
domain_keys = sorted(
|
||||
{k for k in be_the_fun_in_de_funes if k not in ["id"]}
|
||||
) # Make it deterministic
|
||||
|
||||
payload = {k: be_the_fun_in_de_funes[k] for k in domain_keys}
|
||||
|
||||
missing_key = "title"
|
||||
|
||||
payload.pop(missing_key)
|
||||
|
||||
response = client.post("/pydantic_movies/", json=payload)
|
||||
|
||||
assert 400 <= response.status_code < 500
|
||||
|
||||
assert missing_key in response.text
|
||||
|
||||
def test_payload_content_bad_format_detail(self):
|
||||
be_the_fun_in_de_funes = {
|
||||
"id": 1,
|
||||
"title": "La Grande Vadrouille",
|
||||
"description": "During World War II, two French civilians and a downed English Bomber Crew set "
|
||||
"out from Paris to cross the demarcation line between Nazi-occupied Northern France and the "
|
||||
"South. From there they will be able to escape to England. First, they must avoid German troops -"
|
||||
"and the consequences of their own blunders.",
|
||||
"genres": ["Comedy", "War"],
|
||||
"release_date": "1966-12-07",
|
||||
"vote_average": 7.7,
|
||||
"vote_count": 1123,
|
||||
}
|
||||
|
||||
domain_keys = sorted(
|
||||
{k for k in be_the_fun_in_de_funes if k not in ["id"]}
|
||||
) # Make it deterministic
|
||||
|
||||
payload = {k: be_the_fun_in_de_funes[k] for k in domain_keys}
|
||||
|
||||
missing_key = "title"
|
||||
|
||||
payload.pop(missing_key)
|
||||
|
||||
response = client.post("/pydantic_movies/", json=payload)
|
||||
|
||||
assert 400 <= response.status_code < 500
|
||||
|
||||
assert response.status_code == 400
|
||||
|
||||
def test_payload_content_in_and_out_loopback_pydantic(self):
|
||||
be_the_fun_in_de_funes = {
|
||||
"id": 1,
|
||||
|
|
Loading…
Reference in New Issue