From c3af9d53d53f37d1a08c8f37f3ef6143e02f4a13 Mon Sep 17 00:00:00 2001 From: DonHaul Date: Tue, 27 Aug 2024 17:27:45 +0200 Subject: [PATCH] backoffice: search for email_addresses as well * ref: cern-sis/issues-inspire/issues/548 --- .../backoffice/workflows/tests/test_views.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/backoffice/backoffice/workflows/tests/test_views.py b/backoffice/backoffice/workflows/tests/test_views.py index 0f6ff9a5..5c9a2a61 100644 --- a/backoffice/backoffice/workflows/tests/test_views.py +++ b/backoffice/backoffice/workflows/tests/test_views.py @@ -492,7 +492,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 +516,27 @@ 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" + def test_search_data_email(self): + self.api_client.force_authenticate(user=self.admin) + + email = "john.smith@something.ch" + + url = reverse("search:workflow-list") + + urls = [ + url + f"?search={email}", + url + f"?search=data.email_addresses.value:{email}", + ] + + for url in urls: + 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)