diff --git a/backoffice/backoffice/workflows/tests/test_views.py b/backoffice/backoffice/workflows/tests/test_views.py index 0f6ff9a5..41a3521d 100644 --- a/backoffice/backoffice/workflows/tests/test_views.py +++ b/backoffice/backoffice/workflows/tests/test_views.py @@ -11,6 +11,7 @@ from django.test import TransactionTestCase from django.urls import reverse from django_opensearch_dsl.registries import registry +from parameterized import parameterized from rest_framework import status from rest_framework.test import APIClient @@ -492,7 +493,7 @@ def setUpClass(cls): ], "name": {"value": "Smith, John", "preferred_name": "John Smith"}, "email_addresses": [ - {"value": "john.smith@someting.ch", "current": True} + {"value": "john.smith@something.ch", "current": True} ], }, status=StatusChoices.RUNNING, @@ -516,10 +517,22 @@ def test_search_data_name(self): response = self.api_client.get(url) results = response.json()["results"] - assert len(results) == 1 assert results[0]["data"]["name"]["value"] == "Smith, John" + @parameterized.expand(["?search=", "?search=data.email_addresses.value:"]) + def test_search_data_email(self, query_params): + self.api_client.force_authenticate(user=self.admin) + + email = "john.smith@something.ch" + + url = reverse("search:workflow-list") + f"{query_params}{email}" + + response = self.api_client.get(url) + results = response.json()["results"] + assert len(results) == 1 + assert results[0]["data"]["email_addresses"][0]["value"] == email + def test_filter_status(self): self.api_client.force_authenticate(user=self.admin) diff --git a/backoffice/poetry.lock b/backoffice/poetry.lock index 17d35cb1..ae9690d8 100644 --- a/backoffice/poetry.lock +++ b/backoffice/poetry.lock @@ -2303,6 +2303,20 @@ files = [ {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, ] +[[package]] +name = "parameterized" +version = "0.9.0" +description = "Parameterized testing with any Python test framework" +optional = false +python-versions = ">=3.7" +files = [ + {file = "parameterized-0.9.0-py2.py3-none-any.whl", hash = "sha256:4e0758e3d41bea3bbd05ec14fc2c24736723f243b28d702081aef438c9372b1b"}, + {file = "parameterized-0.9.0.tar.gz", hash = "sha256:7fc905272cefa4f364c1a3429cbbe9c0f98b793988efb5bf90aac80f08db09b1"}, +] + +[package.extras] +dev = ["jinja2"] + [[package]] name = "parso" version = "0.8.3" @@ -4018,4 +4032,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "~3.11" -content-hash = "acdf5b76465425aef6dd682721e4b867f8abf311305398f7f5fbdb6d89199066" +content-hash = "399b741c239a851673d0c8fcce9949302fab3a6f82d7977f191a048eb3d91e8d" diff --git a/backoffice/pyproject.toml b/backoffice/pyproject.toml index 401d7815..2c72f55f 100644 --- a/backoffice/pyproject.toml +++ b/backoffice/pyproject.toml @@ -150,6 +150,7 @@ opensearch-py = "2.6.0" djangorestframework-simplejwt = "^5.3.1" django-json-widget = "^2.0.1" sentry-sdk = "1.19.1" +parameterized = "^0.9.0" [tool.poetry.dev-dependencies] factory-boy = "3.3.0"