mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Testing: Inject mongo_url argument earlier (#5706)
* Inject mongo_url argument earlier * monkeypatch instead of os.environ --------- Co-authored-by: Petr Kalis <petr.kalis@gmail.com>
This commit is contained in:
parent
e7cd31f2dd
commit
38427b5eec
1 changed files with 5 additions and 3 deletions
|
|
@ -105,7 +105,7 @@ class ModuleUnitTest(BaseTest):
|
|||
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")
|
||||
|
|
@ -129,6 +129,9 @@ class ModuleUnitTest(BaseTest):
|
|||
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
|
||||
|
|
@ -150,8 +153,7 @@ class ModuleUnitTest(BaseTest):
|
|||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue