diff --git a/tests/integration/test_int_genre.py b/tests/integration/test_int_genre.py index 59823db..36b01ee 100644 --- a/tests/integration/test_int_genre.py +++ b/tests/integration/test_int_genre.py @@ -1,26 +1,83 @@ from sqlalchemy import select from sqlalchemy.exc import IntegrityError import pytest -from the_works.database import db from the_works.models import Genre -def test_genre_create(client, _app): - """Integrated testing of adding a Genre record.""" - response = client.post("/genre/create", data={"form_Genre": "spam"}, follow_redirects=True) - # assert there was exactly 1 redirect - assert len(response.history) == 1 - # assert the redirect led to the correct page - assert response.request.path == "/genre/all" - assert response.status_code == 200 +class TestIntGenreRead: + """Integrated tests for reading all records.""" - # assert record was successfully added to DB - with _app.app_context(): - genre = db.session.scalars(select(Genre).where(Genre.Genre == "spam")).all() - assert len(genre) == 1 - assert isinstance(genre[0], Genre) + def test_records_read(self, client, db): + """test reading records""" + response = client.get("/genre/all", follow_redirects=True) + # good status code + assert response.status_code == 200 + # two records returned + assert response.data.count(b'