Skip to content

Commit

Permalink
EKIRJASTO-131 Fix new route tests
Browse files Browse the repository at this point in the history
  • Loading branch information
natlibfi-kaisa committed Dec 30, 2024
1 parent 11e7055 commit 312aa7c
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions tests/api/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def test_related_books(self, fixture: RouteTestFixture):


class TestSelectedBooksController:
CONTROLLER_NAME = "selected_book_controller"
CONTROLLER_NAME = "select_books"

@pytest.fixture(scope="function")
def fixture(self, route_test: RouteTestFixture) -> RouteTestFixture:
Expand All @@ -337,21 +337,31 @@ def fixture(self, route_test: RouteTestFixture) -> RouteTestFixture:
def test_select(self, fixture: RouteTestFixture):
url = "/works/<identifier_type>/<identifier>/select_book"
fixture.assert_authenticated_request_calls(
url, fixture.controller.select, "<identifier_type>", "<identifier>", None, None # type: ignore[union-attr]
url,
fixture.controller.select, # type: ignore[union-attr]
"<identifier_type>",
"<identifier>",
http_method="POST",
)
fixture.assert_supported_methods(url, "POST")

def test_unselect(self, fixture: RouteTestFixture):
url = "/works/<identifier_type>/<identifier>/unselect_book"
fixture.assert_authenticated_request_calls(
url, fixture.controller.unselect, "<identifier_type>", "<identifier>", None, None # type: ignore[union-attr]
url,
fixture.controller.unselect, # type: ignore[union-attr]
"<identifier_type>",
"<identifier>",
http_method="DELETE",
)
fixture.assert_supported_methods(url, "DELETE")

def test_detail(self, fixture: RouteTestFixture):
url = "/selected_books/<identifier_type>/<identifier>"
fixture.assert_authenticated_request_calls(
url, fixture.controller.detail, "<identifier_type>", "<identifier>", None, None # type: ignore[union-attr]
fixture.assert_request_calls_method_using_identifier(
url,
fixture.controller.detail, # type: ignore[union-attr]
"<identifier_type>",
"<identifier>",
authenticated=True,
)
fixture.assert_supported_methods(url, "GET", "DELETE")

Expand Down

0 comments on commit 312aa7c

Please sign in to comment.