From 11e7055c1cefd35bc56468e50ed4662d222d118c Mon Sep 17 00:00:00 2001 From: Kaisa Kuivalahti Date: Mon, 23 Dec 2024 13:55:15 +0200 Subject: [PATCH] EKIRJASTO-131 Add tests for new routes --- tests/api/test_routes.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/api/test_routes.py b/tests/api/test_routes.py index 3d5197d6a..22ef7aea7 100644 --- a/tests/api/test_routes.py +++ b/tests/api/test_routes.py @@ -326,6 +326,44 @@ def test_related_books(self, fixture: RouteTestFixture): ) +class TestSelectedBooksController: + CONTROLLER_NAME = "selected_book_controller" + + @pytest.fixture(scope="function") + def fixture(self, route_test: RouteTestFixture) -> RouteTestFixture: + route_test.set_controller_name(self.CONTROLLER_NAME) + return route_test + + def test_select(self, fixture: RouteTestFixture): + url = "/works///select_book" + fixture.assert_authenticated_request_calls( + url, fixture.controller.select, "", "", None, None # type: ignore[union-attr] + ) + fixture.assert_supported_methods(url, "POST") + + def test_unselect(self, fixture: RouteTestFixture): + url = "/works///unselect_book" + fixture.assert_authenticated_request_calls( + url, fixture.controller.unselect, "", "", None, None # type: ignore[union-attr] + ) + fixture.assert_supported_methods(url, "DELETE") + + def test_detail(self, fixture: RouteTestFixture): + url = "/selected_books//" + fixture.assert_authenticated_request_calls( + url, fixture.controller.detail, "", "", None, None # type: ignore[union-attr] + ) + fixture.assert_supported_methods(url, "GET", "DELETE") + + def test_selected_books(self, fixture: RouteTestFixture): + url = "/selected_books" + fixture.assert_authenticated_request_calls( + url, + fixture.controller.fetch_books, # type: ignore[union-attr] + ) + fixture.assert_supported_methods(url, "GET") + + class TestAnalyticsController: CONTROLLER_NAME = "analytics_controller"