Add a test for count
This commit is contained in:
parent
daec71fe70
commit
0c1bdba85f
|
@ -112,6 +112,7 @@ class BaseCrud(unittest.TestCase):
|
|||
def test_list_movies(self):
|
||||
response = client.get("/movies/")
|
||||
assert response.status_code == 200
|
||||
primary_count = response.json()["count"]
|
||||
# assert response.json() == []
|
||||
|
||||
N = 10
|
||||
|
@ -124,16 +125,21 @@ class BaseCrud(unittest.TestCase):
|
|||
response = client.post("/movies/", json=self.create_payload)
|
||||
assert response.status_code == 200
|
||||
|
||||
movies = client.get("/movies/").json()["movies"]
|
||||
response = client.get("/movies/").json()
|
||||
|
||||
movies = response["movies"]
|
||||
count = response["count"]
|
||||
movies_by_title = {m["title"]: m for m in movies}
|
||||
found = list(movies_by_title[title] for title in names)
|
||||
assert all(movies_by_title[title] for title in names)
|
||||
|
||||
assert count == primary_count + N
|
||||
|
||||
def test_list_movies_payload_format(self):
|
||||
response = client.get("/movies/")
|
||||
assert response.status_code == 200
|
||||
# assert response.json() == []
|
||||
primary_count = response.json()["count"]
|
||||
|
||||
N = 10
|
||||
names = []
|
||||
|
@ -149,6 +155,7 @@ class BaseCrud(unittest.TestCase):
|
|||
|
||||
assert isinstance(movies["count"], int)
|
||||
assert isinstance(movies["movies"], list)
|
||||
assert movies["count"] == primary_count + N
|
||||
|
||||
|
||||
class ApiTestCase(unittest.TestCase):
|
||||
|
|
Loading…
Reference in New Issue