Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix : reparer affichage d'une demande pour un autre ingrédient #1440

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions api/tests/test_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ def test_get_single_declared_ingredient(self):
ingredient = DeclaredIngredientFactory(declaration=declaration)

response = self.client.get(
reverse("api:declared_element", kwargs={"pk": ingredient.id, "type": "ingredient"}), format="json"
reverse("api:declared_element", kwargs={"pk": ingredient.id, "type": "other-ingredient"}), format="json"
)
body = response.json()
self.assertEqual(body["id"], ingredient.id)
Expand All @@ -1699,7 +1699,7 @@ def test_cannot_get_declared_element_unknown_type(self):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
response.json()["globalError"],
"Unknown type: 'unknown' not in ['plant', 'microorganism', 'substance', 'ingredient']",
"Unknown type: 'unknown' not in ['plant', 'microorganism', 'substance', 'other-ingredient']",
)

def test_get_declared_element_not_allowed_not_authenticated(self):
Expand All @@ -1717,7 +1717,7 @@ def test_get_declared_element_not_allowed_not_authenticated(self):
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

response = self.client.get(
reverse("api:declared_element", kwargs={"pk": 1, "type": "ingredient"}), format="json"
reverse("api:declared_element", kwargs={"pk": 1, "type": "other-ingredient"}), format="json"
)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

Expand All @@ -1737,7 +1737,7 @@ def test_get_declared_element_not_allowed_not_instructor(self):
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

response = self.client.get(
reverse("api:declared_element", kwargs={"pk": 1, "type": "ingredient"}), format="json"
reverse("api:declared_element", kwargs={"pk": 1, "type": "other-ingredient"}), format="json"
)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

Expand Down Expand Up @@ -1778,7 +1778,7 @@ def test_request_info_declared_element_not_allowed_not_instructor(self):
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

response = self.client.get(
reverse("api:declared_element_request_info", kwargs={"pk": 1, "type": "ingredient"}), format="json"
reverse("api:declared_element_request_info", kwargs={"pk": 1, "type": "other-ingredient"}), format="json"
)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

Expand Down Expand Up @@ -1818,7 +1818,7 @@ def test_reject_declared_element_not_allowed_not_instructor(self):
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

response = self.client.get(
reverse("api:declared_element_reject", kwargs={"pk": 1, "type": "ingredient"}), format="json"
reverse("api:declared_element_reject", kwargs={"pk": 1, "type": "other-ingredient"}), format="json"
)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

Expand Down
2 changes: 1 addition & 1 deletion api/views/declaration/declared_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ElementMappingMixin:
"element_model": Substance,
"serializer": DeclaredSubstanceSerializer,
},
"ingredient": {
"other-ingredient": {
"model": DeclaredIngredient,
"element_model": Ingredient,
"serializer": DeclaredIngredientSerializer,
Expand Down
Loading