diff --git a/utests/test_api.py b/utests/test_api.py index 371e1b9..7c41db0 100644 --- a/utests/test_api.py +++ b/utests/test_api.py @@ -55,6 +55,17 @@ class BaseCrud(unittest.TestCase): response = client.get("/movies/-1") assert response.status_code == 404 + def test_create_movie_api(self): + name = f"rand_{random.randint(1, 1000)}" + response = client.post("/movies/", json={"title": name}) + + assert response.status_code == 200 + movie_id = response.json()["id"] + assert f"Created {name}" in response.json()["message"] + response = client.get(f"/movies/{movie_id}") + assert response.json()["title"] == name + + def test_list_movies(self): response = client.get("/movies/") # assert response.json() == [] @@ -73,16 +84,6 @@ class BaseCrud(unittest.TestCase): found = list(movies_by_title[title] for title in names) assert all(movies_by_title[title] for title in names) - def test_create_movie_api(self): - name = f"rand_{random.randint(1, 1000)}" - response = client.post("/movies/", json={"title": name}) - - assert response.status_code == 200 - movie_id = response.json()["id"] - assert f"Created {name}" in response.json()["message"] - response = client.get(f"/movies/{movie_id}") - assert response.json()["title"] == name - class ApiTestCase(unittest.TestCase): def test_payload_content_in_and_out_loopback(self):