From 8648a6bcc7c4b0ca01b0c65457203d4cb24fa563 Mon Sep 17 00:00:00 2001 From: DonHaul Date: Tue, 27 Aug 2024 17:27:45 +0200 Subject: [PATCH] backoffice: fix restart with params * ref: cern-sis/issues-inspire/issues/545 --- .../backoffice/workflows/tests/test_views.py | 17 +++++++++++++++-- backoffice/poetry.lock | 16 +++++++++++++++- backoffice/pyproject.toml | 1 + 3 files changed, 31 insertions(+), 3 deletions(-) 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..08e6f58b 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 = "3792d78500a0345b91bebb37193b90820bc1a0beb8838881f6015bbdf6ca3a9d" diff --git a/backoffice/pyproject.toml b/backoffice/pyproject.toml index 401d7815..97c59d7c 100644 --- a/backoffice/pyproject.toml +++ b/backoffice/pyproject.toml @@ -172,6 +172,7 @@ django-coverage-plugin = "3.1.0" pytest-django = "4.5.2" pytest-vcr = "^1.0.2" vcrpy = "^6.0.1" +parameterized = "^0.9.0" [build-system] requires = ["poetry-core>=1.0.0"]