Skip to content

Commit

Permalink
try to fix app.config problem
Browse files Browse the repository at this point in the history
  • Loading branch information
philipkcl committed Oct 10, 2023
1 parent 2bfdafb commit b162649
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 9 additions & 4 deletions doajtest/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions doajtest/selenium_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b162649

Please sign in to comment.