From b1626499499d7097faef034ee61ff3cebc85cf45 Mon Sep 17 00:00:00 2001 From: philip Date: Tue, 10 Oct 2023 10:50:48 +0100 Subject: [PATCH] try to fix app.config problem --- doajtest/helpers.py | 13 +++++++++---- doajtest/selenium_helpers.py | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doajtest/helpers.py b/doajtest/helpers.py index 1e78331360..04515a3e33 100644 --- a/doajtest/helpers.py +++ b/doajtest/helpers.py @@ -120,9 +120,8 @@ class DoajTestCase(TestCase): originals = {} @classmethod - def setUpClass(cls) -> None: - import portality.app # noqa, needed to registing routes - cls.originals = patch_config(app, { + def create_app_patch(cls): + return { "STORE_IMPL": "portality.store.StoreLocal", "STORE_LOCAL_DIR": paths.rel2abs(__file__, "..", "tmp", "store", "main", cls.__name__.lower()), "STORE_TMP_DIR": paths.rel2abs(__file__, "..", "tmp", "store", "tmp", cls.__name__.lower()), @@ -138,7 +137,13 @@ def setUpClass(cls) -> None: "FAKER_SEED": 1, "EVENT_SEND_FUNCTION": "portality.events.shortcircuit.send_event", 'CMS_BUILD_ASSETS_ON_STARTUP': False - }) + } + + @classmethod + def setUpClass(cls) -> None: + import portality.app # noqa, needed to registing routes + + cls.originals = patch_config(app, cls.create_app_patch()) # some unittest will capture log for testing, therefor log level must be DEBUG cls.app_test.logger.setLevel(logging.DEBUG) diff --git a/doajtest/selenium_helpers.py b/doajtest/selenium_helpers.py index f1607288f1..3477b1284c 100644 --- a/doajtest/selenium_helpers.py +++ b/doajtest/selenium_helpers.py @@ -52,8 +52,9 @@ def fix_index_not_found_exception(app): # run doaj server in a background process -def _run_doaj_server(): +def _run_doaj_server(app_batch): try: + patch_config(app.app, app_batch) app.run_server(host=DOAJ_HOST, port=DOAJ_PORT) except Exception as e: if isinstance(e, ESMappingMissingError): @@ -84,7 +85,7 @@ def setUp(self): super().setUp() freeze_support() - self.doaj_process = Process(target=_run_doaj_server, daemon=True) + self.doaj_process = Process(target=_run_doaj_server, args=(self.create_app_patch(),), daemon=True) self.doaj_process.start() # prepare selenium driver