diff --git a/src/tests/routers/generic/test_authentication.py b/src/tests/routers/generic/test_authentication.py index 6dc1a7f9..52f9a24b 100644 --- a/src/tests/routers/generic/test_authentication.py +++ b/src/tests/routers/generic/test_authentication.py @@ -11,14 +11,14 @@ def test_get_all_unauthenticated( ): """You don't need authentication for GET""" response = client_test_resource.get("/test_resources/v0") - assert response.status_code == 200 + assert response.status_code == 200, response.json() assert len(response.json()) == 1 def test_get_unauthenticated(client_test_resource: TestClient, engine_test_resource_filled: Engine): """You don't need authentication for GET""" response = client_test_resource.get("/test_resources/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() def test_platform_get_all_unauthenticated( @@ -26,7 +26,7 @@ def test_platform_get_all_unauthenticated( ): """You don't need authentication for GET""" response = client_test_resource.get("/platforms/example/test_resources/v0") - assert response.status_code == 200 + assert response.status_code == 200, response.json() assert len(response.json()) == 1 @@ -35,7 +35,7 @@ def test_platform_get_unauthenticated( ): """You don't need authentication for GET""" response = client_test_resource.get("/platforms/example/test_resources/v0") - assert response.status_code == 200 + assert response.status_code == 200, response.json() assert len(response.json()) == 1 @@ -43,7 +43,7 @@ def test_delete_unauthenticated( client_test_resource: TestClient, engine_test_resource_filled: Engine ): response = client_test_resource.delete("/test_resources/v0/1") - assert response.status_code == 401 + assert response.status_code == 401, response.json() def test_delete_unauthorized(client_test_resource: TestClient, mocked_token: Mock): @@ -52,7 +52,7 @@ def test_delete_unauthorized(client_test_resource: TestClient, mocked_token: Moc "/test_resources/v0/1", headers={"Authorization": "fake-token"}, ) - assert response.status_code == 403 + assert response.status_code == 403, response.json() response_json = response.json() assert response_json["detail"] == "You do not have permission to edit Aiod resources." @@ -64,14 +64,14 @@ def test_post_unauthorized(client_test_resource: TestClient, mocked_token: Mock) json={"title": "example"}, headers={"Authorization": "fake-token"}, ) - assert response.status_code == 403 + assert response.status_code == 403, response.json() response_json = response.json() assert response_json["detail"] == "You do not have permission to edit Aiod resources." def test_post_unauthenticated(client_test_resource: TestClient): response = client_test_resource.post("/test_resources/v0", json={"title": "example"}) - assert response.status_code == 401 + assert response.status_code == 401, response.json() response_json = response.json() assert ( response_json["detail"] == "This endpoint requires authorization. You need to be logged in." @@ -85,14 +85,14 @@ def test_put_unauthorized(client_test_resource: TestClient, mocked_token: Mock): json={"title": "example"}, headers={"Authorization": "fake-token"}, ) - assert response.status_code == 403 + assert response.status_code == 403, response.json() response_json = response.json() assert response_json["detail"] == "You do not have permission to edit Aiod resources." def test_put_unauthenticated(client_test_resource: TestClient): response = client_test_resource.put("/test_resources/v0/1", json={"title": "example"}) - assert response.status_code == 401 + assert response.status_code == 401, response.json() response_json = response.json() assert ( response_json["detail"] == "This endpoint requires authorization. You need to be logged in." diff --git a/src/tests/routers/generic/test_router_delete.py b/src/tests/routers/generic/test_router_delete.py index 4f0d1185..6dad21e0 100644 --- a/src/tests/routers/generic/test_router_delete.py +++ b/src/tests/routers/generic/test_router_delete.py @@ -33,9 +33,9 @@ def test_happy_path( response = client_test_resource.delete( f"/test_resources/v0/{identifier}", headers={"Authorization": "Fake token"} ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client_test_resource.get("/test_resources/v0/") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert len(response_json) == 1 assert {r["identifier"] for r in response_json} == {1, 2} - {identifier} @@ -64,5 +64,5 @@ def test_non_existent( response = client_test_resource.delete( f"/test_resources/v0/{identifier}", headers={"Authorization": "Fake token"} ) - assert response.status_code == 404 + assert response.status_code == 404, response.json() assert response.json()["detail"] == f"Test_resource '{identifier}' not found in the database." diff --git a/src/tests/routers/generic/test_router_deprecation.py b/src/tests/routers/generic/test_router_deprecation.py index 247b4a32..2dabcdd4 100644 --- a/src/tests/routers/generic/test_router_deprecation.py +++ b/src/tests/routers/generic/test_router_deprecation.py @@ -52,6 +52,6 @@ def test_deprecated_router( kwargs["headers"] = {"Authorization": "fake-token"} response = getattr(client, verb)(url, **kwargs) - assert response.status_code == 200 + assert response.status_code == 200, response.json() assert "deprecated" in response.headers assert response.headers.get("deprecated") == "Thu, 21 Apr 2022 00:00:00 GMT" diff --git a/src/tests/routers/generic/test_router_get.py b/src/tests/routers/generic/test_router_get.py index 7a8ded1b..1f5fe292 100644 --- a/src/tests/routers/generic/test_router_get.py +++ b/src/tests/routers/generic/test_router_get.py @@ -4,7 +4,7 @@ def test_get_happy_path(client_test_resource: TestClient, engine_test_resource_filled: Engine): response = client_test_resource.get("/platforms/example/test_resources/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["title"] == "A title" @@ -14,13 +14,13 @@ def test_get_happy_path(client_test_resource: TestClient, engine_test_resource_f def test_not_found(client_test_resource: TestClient, engine_test_resource_filled: Engine): response = client_test_resource.get("/platforms/example/test_resources/v0/99") - assert response.status_code == 404 + assert response.status_code == 404, response.json() assert response.json()["detail"] == "Test_resource '99' of 'example' not found in the database." def test_wrong_platform(client_test_resource: TestClient, engine_test_resource_filled: Engine): response = client_test_resource.get("/platforms/openml/test_resources/v0/1") - assert response.status_code == 404 + assert response.status_code == 404, response.json() assert response.json()["detail"] == "Test_resource '1' of 'openml' not found in the database." @@ -28,5 +28,5 @@ def test_nonexistent_platform( client_test_resource: TestClient, engine_test_resource_filled: Engine ): response = client_test_resource.get("/platforms/nonexistent_platform/test_resources/v0/1") - assert response.status_code == 400 + assert response.status_code == 400, response.json() assert response.json()["detail"] == "platform 'nonexistent_platform' not recognized." diff --git a/src/tests/routers/generic/test_router_get_all.py b/src/tests/routers/generic/test_router_get_all.py index d4c7f885..a4795192 100644 --- a/src/tests/routers/generic/test_router_get_all.py +++ b/src/tests/routers/generic/test_router_get_all.py @@ -18,7 +18,7 @@ def test_get_all_happy_path(client_test_resource: TestClient, engine_test_resour ) session.commit() response = client_test_resource.get("/test_resources/v0") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert len(response_json) == 2 diff --git a/src/tests/routers/generic/test_router_get_count.py b/src/tests/routers/generic/test_router_get_count.py index 2b0af103..8398b74b 100644 --- a/src/tests/routers/generic/test_router_get_count.py +++ b/src/tests/routers/generic/test_router_get_count.py @@ -18,7 +18,7 @@ def test_get_count_happy_path(client_test_resource: TestClient, engine_test_reso ) session.commit() response = client_test_resource.get("/counts/test_resources/v0") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json == 2 diff --git a/src/tests/routers/generic/test_router_platform_get.py b/src/tests/routers/generic/test_router_platform_get.py index 4f03407b..f37c3dc7 100644 --- a/src/tests/routers/generic/test_router_platform_get.py +++ b/src/tests/routers/generic/test_router_platform_get.py @@ -4,7 +4,7 @@ def test_get_happy_path(client_test_resource: TestClient, engine_test_resource_filled: Engine): response = client_test_resource.get("/test_resources/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["title"] == "A title" @@ -14,5 +14,5 @@ def test_get_happy_path(client_test_resource: TestClient, engine_test_resource_f def test_not_found(client_test_resource: TestClient, engine_test_resource_filled: Engine): response = client_test_resource.get("/test_resources/v0/99") - assert response.status_code == 404 + assert response.status_code == 404, response.json() assert response.json()["detail"] == "Test_resource '99' not found in the database." diff --git a/src/tests/routers/generic/test_router_platform_get_all.py b/src/tests/routers/generic/test_router_platform_get_all.py index ad802c42..83bc4773 100644 --- a/src/tests/routers/generic/test_router_platform_get_all.py +++ b/src/tests/routers/generic/test_router_platform_get_all.py @@ -22,7 +22,7 @@ def test_get_all_happy_path(client_test_resource: TestClient, engine_test_resour ) session.commit() response = client_test_resource.get("/platforms/example/test_resources/v0") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert len(response_json) == 2 diff --git a/src/tests/routers/generic/test_router_post.py b/src/tests/routers/generic/test_router_post.py index 3f735dc7..63e0bac6 100644 --- a/src/tests/routers/generic/test_router_post.py +++ b/src/tests/routers/generic/test_router_post.py @@ -17,10 +17,10 @@ def test_unicode(client_test_resource: TestClient, title: str, mocked_privileged json={"title": title, "platform": "example", "platform_identifier": "1"}, headers={"Authorization": "Fake token"}, ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() assert response.json() == {"identifier": 1} response = client_test_resource.get("/test_resources/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["title"] == title @@ -31,7 +31,7 @@ def test_missing_value(client_test_resource: TestClient, mocked_privileged_token response = client_test_resource.post( "/test_resources/v0", json=body, headers={"Authorization": "Fake token"} ) - assert response.status_code == 422 + assert response.status_code == 422, response.json() assert response.json()["detail"] == [ {"loc": ["body", "title"], "msg": "field required", "type": "value_error.missing"} ] @@ -43,7 +43,7 @@ def test_null_value(client_test_resource: TestClient, mocked_privileged_token: M response = client_test_resource.post( "/test_resources/v0", json=body, headers={"Authorization": "Fake token"} ) - assert response.status_code == 422 + assert response.status_code == 422, response.json() assert response.json()["detail"] == [ { "loc": ["body", "title"], @@ -58,10 +58,10 @@ def test_posting_same_item_twice(client_test_resource: TestClient, mocked_privil headers = {"Authorization": "Fake token"} body = {"title": "title1", "platform": "example", "platform_identifier": "1"} response = client_test_resource.post("/test_resources/v0", json=body, headers=headers) - assert response.status_code == 200 + assert response.status_code == 200, response.json() body = {"title": "title2", "platform": "example", "platform_identifier": "1"} response = client_test_resource.post("/test_resources/v0", json=body, headers=headers) - assert response.status_code == 409 + assert response.status_code == 409, response.json() assert ( response.json()["detail"] == "There already exists a test_resource with the same " "platform and platform_identifier, with identifier=1." @@ -75,10 +75,10 @@ def test_no_platform_no_platform_identifier( headers = {"Authorization": "Fake token"} body = {"title": "title1", "platform": None, "platform_identifier": None} response = client_test_resource.post("/test_resources/v0", json=body, headers=headers) - assert response.status_code == 200 + assert response.status_code == 200, response.json() body = {"title": "title2", "platform": None, "platform_identifier": None} response = client_test_resource.post("/test_resources/v0", json=body, headers=headers) - assert response.status_code == 200 + assert response.status_code == 200, response.json() def test_no_platform_with_platform_identifier( @@ -88,7 +88,7 @@ def test_no_platform_with_platform_identifier( headers = {"Authorization": "Fake token"} body = {"title": "title1", "platform": None, "platform_identifier": "1"} response = client_test_resource.post("/test_resources/v0", json=body, headers=headers) - assert response.status_code == 400 + assert response.status_code == 400, response.json() assert ( response.json()["detail"] == "If platform is NULL, platform_identifier should also be " "NULL, and vice versa." @@ -102,7 +102,7 @@ def test_platform_with_no_platform_identifier( headers = {"Authorization": "Fake token"} body = {"title": "title1", "platform": "example", "platform_identifier": None} response = client_test_resource.post("/test_resources/v0", json=body, headers=headers) - assert response.status_code == 400 + assert response.status_code == 400, response.json() assert ( response.json()["detail"] == "If platform is NULL, platform_identifier should also be " "NULL, and vice versa." @@ -115,7 +115,7 @@ def test_same_title_twice(client_test_resource: TestClient, mocked_privileged_to headers = {"Authorization": "Fake token"} body = {"title": "title1", "platform": None, "platform_identifier": None} response = client_test_resource.post("/test_resources/v0", json=body, headers=headers) - assert response.status_code == 200 + assert response.status_code == 200, response.json() body = {"title": "title1", "platform": None, "platform_identifier": None} response = client_test_resource.post("/test_resources/v0", json=body, headers=headers) assert response.status_code == 409 diff --git a/src/tests/routers/generic/test_router_put.py b/src/tests/routers/generic/test_router_put.py index 97d21ac9..5d2f163a 100644 --- a/src/tests/routers/generic/test_router_put.py +++ b/src/tests/routers/generic/test_router_put.py @@ -23,9 +23,9 @@ def test_unicode( json={"title": title, "platform": "openml", "platform_identifier": "2"}, headers={"Authorization": "Fake token"}, ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client_test_resource.get("/test_resources/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["title"] == title assert response_json["platform"] == "openml" @@ -43,7 +43,7 @@ def test_non_existent( json={"title": "new_title", "platform": "other", "platform_identifier": "2"}, headers={"Authorization": "Fake token"}, ) - assert response.status_code == 404 + assert response.status_code == 404, response.json() response_json = response.json() assert response_json["detail"] == "Test_resource '2' not found in the database." @@ -58,7 +58,7 @@ def test_too_long_name( response = client_test_resource.put( "/test_resources/v0/1", json={"title": name}, headers={"Authorization": "Fake token"} ) - assert response.status_code == 422 + assert response.status_code == 422, response.json() response_json = response.json() assert response_json["detail"] == [ { @@ -85,7 +85,7 @@ def test_no_platform_with_platform_identifier( json={"title": "title", "platform": "other", "platform_identifier": None}, headers={"Authorization": "Fake token"}, ) - assert response.status_code == 400 + assert response.status_code == 400, response.json() assert ( response.json()["detail"] == "If platform is NULL, platform_identifier should also be " "NULL, and vice versa." diff --git a/src/tests/routers/generic/test_router_relations.py b/src/tests/routers/generic/test_router_relations.py index 7d84f847..57b0b174 100644 --- a/src/tests/routers/generic/test_router_relations.py +++ b/src/tests/routers/generic/test_router_relations.py @@ -159,7 +159,7 @@ def client_with_testobject(engine_test_resource) -> TestClient: def test_get_happy_path(client_with_testobject: TestClient): response = client_with_testobject.get("/test_resources/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["identifier"] == 1 @@ -171,7 +171,7 @@ def test_get_happy_path(client_with_testobject: TestClient): def test_get_all_happy_path(client_with_testobject: TestClient): response = client_with_testobject.get("/test_resources/v0") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert "deprecated" not in response.headers @@ -201,7 +201,7 @@ def test_post_happy_path(client_with_testobject: TestClient, mocked_privileged_t }, headers={"Authorization": "Fake token"}, ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() objects = client_with_testobject.get("/test_resources/v0").json() obj = objects[-1] assert obj["identifier"] == 5 @@ -232,7 +232,7 @@ def test_put_happy_path(client_with_testobject: TestClient, mocked_privileged_to }, headers={"Authorization": "Fake token"}, ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() changed_resource = client_with_testobject.get("/test_resources/v0/4").json() assert changed_resource["title"] == "new title" assert changed_resource["named_string"] == "new_string" diff --git a/src/tests/routers/generic/test_router_scheme.py b/src/tests/routers/generic/test_router_scheme.py index b1a989c7..5a33dd8c 100644 --- a/src/tests/routers/generic/test_router_scheme.py +++ b/src/tests/routers/generic/test_router_scheme.py @@ -54,7 +54,7 @@ def test_resources_aiod( for client in [client_test_resource_other_schema, client_test_resource]: response = client.get("/test_resources/v0" + schema_string) - assert response.status_code == 200 + assert response.status_code == 200, response.json() json_ = response.json() assert len(json_) == 1 assert json_[0]["title"] == "A title" @@ -70,7 +70,7 @@ def test_resource_aiod( ): for client in [client_test_resource_other_schema, client_test_resource]: response = client.get("/test_resources/v0/1" + schema_string) - assert response.status_code == 200 + assert response.status_code == 200, response.json() json_ = response.json() assert json_["title"] == "A title" assert "title_with_alternative_name" not in json_ @@ -79,7 +79,7 @@ def test_resource_aiod( @pytest.mark.parametrize("url_part", ["?schema=other-schema", "/1?schema=other-schema"]) def test_aiod_only_other_schema(client_test_resource: TestClient, url_part: str): response = client_test_resource.get("/test_resources/v0" + url_part) - assert response.status_code == 422 + assert response.status_code == 422, response.json() assert response.json()["detail"][0]["msg"] == "unexpected value; permitted: 'aiod'" @@ -87,7 +87,7 @@ def test_resources_other_schema( client_test_resource_other_schema: TestClient, engine_test_resource_filled: Engine ): response = client_test_resource_other_schema.get("/test_resources/v0?schema=other-schema") - assert response.status_code == 200 + assert response.status_code == 200, response.json() json_ = response.json() assert len(json_) == 1 assert json_[0]["title_with_alternative_name"] == "A title" @@ -98,7 +98,7 @@ def test_resource_other_schema( client_test_resource_other_schema: TestClient, engine_test_resource_filled: Engine ): response = client_test_resource_other_schema.get("/test_resources/v0/1?schema=other-schema") - assert response.status_code == 200 + assert response.status_code == 200, response.json() json_ = response.json() assert json_["title_with_alternative_name"] == "A title" assert "title" not in json_ @@ -109,6 +109,6 @@ def test_resource_other_schema( ) def test_nonexistent_schema(client_test_resource_other_schema: TestClient, url: str): response = client_test_resource_other_schema.get(url) - assert response.status_code == 422 + assert response.status_code == 422, response.json() msg = response.json()["detail"][0]["msg"] assert msg == "unexpected value; permitted: 'aiod', 'other-schema'" diff --git a/src/tests/routers/test_router_computational_resource.py b/src/tests/routers/test_router_computational_resource.py index e9abb4ba..a9671cd5 100644 --- a/src/tests/routers/test_router_computational_resource.py +++ b/src/tests/routers/test_router_computational_resource.py @@ -79,10 +79,10 @@ def test_happy_path(client: TestClient, engine: Engine, mocked_privileged_token: response = client.post( "/computational_resources/v0", json=body, headers={"Authorization": "Fake token"} ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/computational_resources/v0/3") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["identifier"] == 3 @@ -116,14 +116,16 @@ def test_happy_path(client: TestClient, engine: Engine, mocked_privileged_token: response = client.delete( "/computational_resources/v0/3", headers={"Authorization": "Fake token"} ) - assert response.status_code == 400 # you cannot delete the parent of other resources + assert ( + response.status_code == 400 + ), response.json() # you cannot delete the parent of other resources body["hasPart"] = [] body["isPartOf"] = [] response = client.put( "/computational_resources/v0/3", json=body, headers={"Authorization": "Fake token"} ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.delete( "/computational_resources/v0/3", headers={"Authorization": "Fake token"} ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() diff --git a/src/tests/routers/test_router_dataset.py b/src/tests/routers/test_router_dataset.py index 965a8499..4c8139f4 100644 --- a/src/tests/routers/test_router_dataset.py +++ b/src/tests/routers/test_router_dataset.py @@ -85,10 +85,10 @@ def test_happy_path(client: TestClient, engine: Engine, mocked_privileged_token: ], } response = client.post("/datasets/v0", json=body, headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/datasets/v0/3") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["identifier"] == 3 @@ -172,7 +172,7 @@ def test_delete(client: TestClient, engine: Engine, mocked_privileged_token: Moc ) session.commit() response = client.delete("/datasets/v0/1", headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() with Session(engine) as session: # TODOs will be fixed in https://github.com/aiondemand/AIOD-rest-api/issues/72 diff --git a/src/tests/routers/test_router_educational_resource.py b/src/tests/routers/test_router_educational_resource.py index 9cebbbaa..26a9baf7 100644 --- a/src/tests/routers/test_router_educational_resource.py +++ b/src/tests/routers/test_router_educational_resource.py @@ -46,10 +46,10 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): response = client.post( "/educational_resources/v0", json=body, headers={"Authorization": "Fake token"} ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/educational_resources/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["identifier"] == 1 @@ -94,4 +94,4 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): } response = client.delete("/educational_resources/v0/1", headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() diff --git a/src/tests/routers/test_router_event.py b/src/tests/routers/test_router_event.py index e52c4297..b6eca746 100644 --- a/src/tests/routers/test_router_event.py +++ b/src/tests/routers/test_router_event.py @@ -68,10 +68,10 @@ def test_happy_path(client: TestClient, engine: Engine, mocked_privileged_token: "business_categories": ["business category 1", "business category 2"], } response = client.post("/events/v0", json=body, headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/events/v0/2") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["identifier"] == 2 @@ -99,7 +99,7 @@ def test_happy_path(client: TestClient, engine: Engine, mocked_privileged_token: } response = client.delete("/events/v0/2", headers={"Authorization": "Fake token"}) - assert response.status_code == 400 + assert response.status_code == 400, response.json() assert ( response.json()["detail"] == "This resource cannot be deleted, because other resources " "are related to it." diff --git a/src/tests/routers/test_router_news.py b/src/tests/routers/test_router_news.py index f04b23f7..53f76fec 100644 --- a/src/tests/routers/test_router_news.py +++ b/src/tests/routers/test_router_news.py @@ -24,10 +24,10 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): "business_categories": ["business category 1", "business category 2"], } response = client.post("/news/v0", json=body, headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/news/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["identifier"] == 1 @@ -50,4 +50,4 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): "business category 2", } response = client.delete("/news/v0/1", headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() diff --git a/src/tests/routers/test_router_organisation.py b/src/tests/routers/test_router_organisation.py index 52378da3..a5249d85 100644 --- a/src/tests/routers/test_router_organisation.py +++ b/src/tests/routers/test_router_organisation.py @@ -47,10 +47,10 @@ def test_happy_path(client: TestClient, engine: Engine, mocked_privileged_token: } response = client.post("/organisations/v0", json=body, headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/organisations/v0/2") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["identifier"] == 2 @@ -70,9 +70,11 @@ def test_happy_path(client: TestClient, engine: Engine, mocked_privileged_token: assert set(response_json["departments"]) == {1} response = client.delete("/organisations/v0/2", headers={"Authorization": "Fake token"}) - assert response.status_code == 400 # you cannot delete the parent of other resources + assert ( + response.status_code == 400 + ), response.json() # you cannot delete the parent of other resources body["departments"] = [] response = client.put("organisations/v0/2", json=body, headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.delete("/organisations/v0/2", headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() diff --git a/src/tests/routers/test_router_platform.py b/src/tests/routers/test_router_platform.py index 0a8c8501..13e8c7bd 100644 --- a/src/tests/routers/test_router_platform.py +++ b/src/tests/routers/test_router_platform.py @@ -11,9 +11,9 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): keycloak_openid.userinfo = mocked_privileged_token body = {"name": "my_favourite_platform"} response = client.post("/platforms/v0", json=body, headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/platforms/v0") - assert response.status_code == 200 + assert response.status_code == 200, response.json() platforms = {p["name"] for p in response.json()} assert platforms == {p.name for p in PlatformName}.union(["my_favourite_platform"]) @@ -23,5 +23,5 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): ) def test_get_platform_of_platform(client: TestClient, url: str): response = client.get(url) - assert response.status_code == 404 + assert response.status_code == 404, response.json() assert response.json()["detail"] == "Not Found" diff --git a/src/tests/routers/test_router_presentation.py b/src/tests/routers/test_router_presentation.py index 2a3a32b2..3894f207 100644 --- a/src/tests/routers/test_router_presentation.py +++ b/src/tests/routers/test_router_presentation.py @@ -26,10 +26,10 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): "is_accessible_for_free": True, } response = client.post("/presentations/v0", json=body, headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/presentations/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["identifier"] == 1 @@ -44,4 +44,4 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): assert response_json["is_accessible_for_free"] response = client.delete("/presentations/v0/1", headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() diff --git a/src/tests/routers/test_router_project.py b/src/tests/routers/test_router_project.py index de86381c..aeffbb99 100644 --- a/src/tests/routers/test_router_project.py +++ b/src/tests/routers/test_router_project.py @@ -31,10 +31,10 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): } response = client.post("/projects/v0", json=body, headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/projects/v0/1") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["platform_identifier"] == "1" @@ -46,4 +46,4 @@ def test_happy_path(client: TestClient, mocked_privileged_token: Mock): assert set(response_json["keywords"]) == {"keyword1", "keyword2"} response = client.delete("/projects/v0/1", headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() diff --git a/src/tests/routers/test_router_publication.py b/src/tests/routers/test_router_publication.py index ba9da79c..d171c804 100644 --- a/src/tests/routers/test_router_publication.py +++ b/src/tests/routers/test_router_publication.py @@ -39,10 +39,10 @@ def test_happy_path(client: TestClient, engine: Engine, mocked_privileged_token: "resource_type": "journal article", } response = client.post("/publications/v0", json=body, headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() response = client.get("/publications/v0/2") - assert response.status_code == 200 + assert response.status_code == 200, response.json() response_json = response.json() assert response_json["identifier"] == 2 @@ -55,4 +55,4 @@ def test_happy_path(client: TestClient, engine: Engine, mocked_privileged_token: assert response_json["datasets"] == [1] response = client.delete("/publications/v0/2", headers={"Authorization": "Fake token"}) - assert response.status_code == 200 + assert response.status_code == 200, response.json() diff --git a/src/tests/uploader/huggingface/test_dataset_uploader.py b/src/tests/uploader/huggingface/test_dataset_uploader.py index 4482698a..8177a7e3 100644 --- a/src/tests/uploader/huggingface/test_dataset_uploader.py +++ b/src/tests/uploader/huggingface/test_dataset_uploader.py @@ -56,7 +56,7 @@ def test_happy_path_new_repository( headers={"Authorization": "Fake token"}, files=files, ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() id_response = response.json() assert id_response == dataset_id @@ -106,7 +106,7 @@ def test_repo_already_exists(client: TestClient, engine: Engine, mocked_privileg headers={"Authorization": "Fake token"}, files=files, ) - assert response.status_code == 200 + assert response.status_code == 200, response.json() id_response = response.json() assert id_response == dataset_id