(backend) adapt test to djangorestframework 3.15.2

A recent update of the djangorestframework changes
the detail message of the 404 error.
We update the tests to match the new message.
This commit is contained in:
Anthony LC
2024-08-19 17:09:56 +02:00
committed by Anthony LC
parent 29c5199b72
commit 07d9e290fa
8 changed files with 21 additions and 17 deletions

View File

@@ -173,7 +173,9 @@ def test_api_document_accesses_retrieve_authenticated_unrelated():
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {
"detail": "No DocumentAccess matches the given query."
}
@pytest.mark.parametrize("via", VIA)

View File

@@ -38,7 +38,7 @@ def test_api_document_versions_list_anonymous_private():
response = APIClient().get(f"/api/v1.0/documents/{document.id!s}/versions/")
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Document matches the given query."}
def test_api_document_versions_list_authenticated_unrelated_public():
@@ -86,7 +86,7 @@ def test_api_document_versions_list_authenticated_unrelated_private():
f"/api/v1.0/documents/{document.id!s}/versions/",
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Document matches the given query."}
@pytest.mark.parametrize("via", VIA)
@@ -169,7 +169,7 @@ def test_api_document_versions_retrieve_anonymous_private():
response = APIClient().get(url)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Document matches the given query."}
def test_api_document_versions_retrieve_authenticated_unrelated_public():
@@ -211,7 +211,7 @@ def test_api_document_versions_retrieve_authenticated_unrelated_private():
f"/api/v1.0/documents/{document.id!s}/versions/{version_id:s}/",
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Document matches the given query."}
@pytest.mark.parametrize("via", VIA)
@@ -434,7 +434,7 @@ def test_api_document_versions_delete_authenticated_private():
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Document matches the given query."}
@pytest.mark.parametrize("role", ["reader", "editor"])

View File

@@ -45,7 +45,7 @@ def test_api_documents_retrieve_anonymous_not_public():
response = APIClient().get(f"/api/v1.0/documents/{document.id!s}/")
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Document matches the given query."}
def test_api_documents_retrieve_authenticated_unrelated_public():
@@ -101,7 +101,7 @@ def test_api_documents_retrieve_authenticated_unrelated_not_public():
f"/api/v1.0/documents/{document.id!s}/",
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Document matches the given query."}
def test_api_documents_retrieve_authenticated_related_direct():
@@ -184,7 +184,7 @@ def test_api_documents_retrieve_authenticated_related_team_none(mock_user_get_te
response = client.get(f"/api/v1.0/documents/{document.id!s}/")
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Document matches the given query."}
@pytest.mark.parametrize(

View File

@@ -58,7 +58,7 @@ def test_api_documents_update_authenticated_unrelated():
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Document matches the given query."}
document.refresh_from_db()
document_values = serializers.DocumentSerializer(instance=document).data

View File

@@ -44,7 +44,7 @@ def test_api_templates_generate_document_anonymous_not_public():
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Template matches the given query."}
def test_api_templates_generate_document_authenticated_public():
@@ -87,7 +87,7 @@ def test_api_templates_generate_document_authenticated_not_public():
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Template matches the given query."}
@pytest.mark.parametrize("via", VIA)

View File

@@ -41,7 +41,7 @@ def test_api_templates_retrieve_anonymous_not_public():
response = APIClient().get(f"/api/v1.0/templates/{template.id!s}/")
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Template matches the given query."}
def test_api_templates_retrieve_authenticated_unrelated_public():
@@ -94,7 +94,7 @@ def test_api_templates_retrieve_authenticated_unrelated_not_public():
f"/api/v1.0/templates/{template.id!s}/",
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Template matches the given query."}
def test_api_templates_retrieve_authenticated_related_direct():
@@ -174,7 +174,7 @@ def test_api_templates_retrieve_authenticated_related_team_none(mock_user_get_te
response = client.get(f"/api/v1.0/templates/{template.id!s}/")
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Template matches the given query."}
@pytest.mark.parametrize(

View File

@@ -58,7 +58,7 @@ def test_api_templates_update_authenticated_unrelated():
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {"detail": "No Template matches the given query."}
template.refresh_from_db()
template_values = serializers.TemplateSerializer(instance=template).data

View File

@@ -170,7 +170,9 @@ def test_api_template_accesses_retrieve_authenticated_unrelated():
)
assert response.status_code == 404
assert response.json() == {"detail": "Not found."}
assert response.json() == {
"detail": "No TemplateAccess matches the given query."
}
@pytest.mark.parametrize("via", VIA)