Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Testing: Inject mongo_url argument earlier (#5706)
Browse files Browse the repository at this point in the history
* Inject mongo_url argument earlier

* monkeypatch instead of os.environ

---------

Co-authored-by: Petr Kalis <[email protected]>
  • Loading branch information
tokejepsen and kalisp authored Oct 12, 2023
1 parent e7cd31f commit 38427b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/lib/testing_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def output_folder_url(self, download_test_data):
yield path

@pytest.fixture(scope="module")
def env_var(self, monkeypatch_session, download_test_data):
def env_var(self, monkeypatch_session, download_test_data, mongo_url):
"""Sets temporary env vars from json file."""
env_url = os.path.join(download_test_data, "input",
"env_vars", "env_var.json")
Expand All @@ -129,6 +129,9 @@ def env_var(self, monkeypatch_session, download_test_data):
monkeypatch_session.setenv(key, str(value))

#reset connection to openpype DB with new env var
if mongo_url:
monkeypatch_session.setenv("OPENPYPE_MONGO", mongo_url)

import openpype.settings.lib as sett_lib
sett_lib._SETTINGS_HANDLER = None
sett_lib._LOCAL_SETTINGS_HANDLER = None
Expand All @@ -150,8 +153,7 @@ def db_setup(self, download_test_data, env_var, monkeypatch_session,
request, mongo_url):
"""Restore prepared MongoDB dumps into selected DB."""
backup_dir = os.path.join(download_test_data, "input", "dumps")

uri = mongo_url or os.environ.get("OPENPYPE_MONGO")
uri = os.environ.get("OPENPYPE_MONGO")
db_handler = DBHandler(uri)
db_handler.setup_from_dump(self.TEST_DB_NAME, backup_dir,
overwrite=True,
Expand Down

0 comments on commit 38427b5

Please sign in to comment.