From 145d92a1ae14a63fc566083a7f13fb50923fa5e1 Mon Sep 17 00:00:00 2001 From: msramalho <19508417+msramalho@users.noreply.github.com> Date: Fri, 18 Oct 2024 19:51:09 +0100 Subject: [PATCH] fixing test with new test files --- src/tests/endpoints/test_default.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tests/endpoints/test_default.py b/src/tests/endpoints/test_default.py index 0d46a99..cfa6fcf 100644 --- a/src/tests/endpoints/test_default.py +++ b/src/tests/endpoints/test_default.py @@ -24,10 +24,11 @@ def test_endpoint_home_with_groups(m1, m2, m3, client_with_auth): assert "groups" in j assert j["groups"] == ["group1", "group2"] + @patch("endpoints.default.bearer_security", new_callable=AsyncMock) @patch("endpoints.default.get_user_auth", new_callable=AsyncMock, return_value="test@example.com") @patch("endpoints.default.crud.get_user_groups", side_effect=Exception('mocked error')) -def test_endpoint_home_with_groups_exception(m1, m2, m3, client_with_auth): # mocks call that triggers an internal error +def test_endpoint_home_with_groups_exception(m1, m2, m3, client_with_auth): # mocks call that triggers an internal error r = client_with_auth.get("/") assert r.status_code == 200 j = r.json() @@ -47,10 +48,12 @@ def test_endpoint_groups_403(client): assert r.status_code == 403 -def test_endpoint_groups_empty(client_with_auth): +def test_endpoint_groups_rick_and_morty(client_with_auth): r = client_with_auth.get("/groups") assert r.status_code == 200 - assert r.json() == [] + assert len(j := r.json()) == 2 + assert 'animated-characters' in j + assert 'spaceship' in j @patch("endpoints.default.crud.get_user_groups", return_value=["group1", "group2"])