From 4a9162b37a2c539ad95f5b7d2997d6ca793f6d7e Mon Sep 17 00:00:00 2001 From: Ramakrishna Sakhamuru Date: Thu, 7 Nov 2024 12:01:15 +0530 Subject: [PATCH] Added Application to ascii folding --- doajtest/fixtures/v2/applications.py | 11 +++++++ doajtest/unit/test_query.py | 32 +++++++++++++++++++ .../migrate/3490_ascii_folding/migrate.json | 5 +++ portality/models/v2/application.py | 2 +- 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/doajtest/fixtures/v2/applications.py b/doajtest/fixtures/v2/applications.py index bda2eca937..8c862f9302 100644 --- a/doajtest/fixtures/v2/applications.py +++ b/doajtest/fixtures/v2/applications.py @@ -20,6 +20,17 @@ def make_update_request_source(): @staticmethod def make_application_source(): return deepcopy(APPLICATION_SOURCE) + + @staticmethod + def make_application_with_data(title=None, publisher_name=None, country=None): + application = deepcopy(APPLICATION_SOURCE) + if title: + application["bibjson"]["title"] = title + if publisher_name: + application["bibjson"]["publisher"]["name"] = publisher_name + if country: + application["bibjson"]["publisher"]["country"] = country + return application @staticmethod def make_many_application_sources(count=2, in_doaj=False): diff --git a/doajtest/unit/test_query.py b/doajtest/unit/test_query.py index 256610a9cc..a40f8d1b82 100644 --- a/doajtest/unit/test_query.py +++ b/doajtest/unit/test_query.py @@ -725,6 +725,38 @@ def test_journal_query_ascii_folding_data(self): assert res['hits']['total']["value"] == 1, res['hits']['total']["value"] + def test_application_query_ascii_folding_data(self): + acc = models.Account(**AccountFixtureFactory.make_managing_editor_source()) + application = models.Application(**ApplicationFixtureFactory + .make_application_with_data(title="Kadınlarının sağlık", + publisher_name="Ankara Üniversitesi", + country="Türkiye", )) + application.save(blocking=True) + qsvc = QueryService() + + # check if journal exist + res = qsvc.search('editor_query', 'suggestion', MATCH_ALL_RAW_QUERY, account=acc, + additional_parameters={}) + assert res['hits']['total']["value"] == 1, res['hits']['total']["value"] + + # check for title search + res = qsvc.search('editor_query', 'suggestion', raw_query("Kadinlarinin saglik"), account=acc, + additional_parameters={"ref": "fqw"}) + + assert res['hits']['total']["value"] == 1, res['hits']['total']["value"] + + # check for publisher name + res = qsvc.search('editor_query', 'suggestion', raw_query("Ankara Universitesi"), account=acc, + additional_parameters={"ref": "fqw"}) + + assert res['hits']['total']["value"] == 1, res['hits']['total']["value"] + + # check for country + res = qsvc.search('editor_query', 'suggestion', raw_query("Turkiye"), account=acc, + additional_parameters={"ref": "fqw"}) + + assert res['hits']['total']["value"] == 1, res['hits']['total']["value"] + def test_search__invalid_from(self): acc = models.Account(**AccountFixtureFactory.make_managing_editor_source()) acc.save(blocking=True) diff --git a/portality/migrate/3490_ascii_folding/migrate.json b/portality/migrate/3490_ascii_folding/migrate.json index 3f76f77392..97f17cd405 100644 --- a/portality/migrate/3490_ascii_folding/migrate.json +++ b/portality/migrate/3490_ascii_folding/migrate.json @@ -11,6 +11,11 @@ "type": "journal", "migrate": true, "set_alias": false + }, + { + "type": "application", + "migrate": true, + "set_alias": false } ] } \ No newline at end of file diff --git a/portality/models/v2/application.py b/portality/models/v2/application.py index c8f42d5c4e..437d049c1e 100644 --- a/portality/models/v2/application.py +++ b/portality/models/v2/application.py @@ -266,7 +266,7 @@ class AllPublisherApplications(DomainObject): MAPPING_OPTS = { "dynamic": None, "coerces": Journal.add_mapping_extensions(app.config["DATAOBJ_TO_MAPPING_DEFAULTS"]), - "exceptions": app.config["ADMIN_NOTES_SEARCH_MAPPING"], + "exceptions": {**app.config["ADMIN_NOTES_SEARCH_MAPPING"], **app.config["JOURNAL_EXCEPTION_MAPPING"]}, "additional_mappings": app.config["ADMIN_NOTES_INDEX_ONLY_FIELDS"] }