mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Add openpype_mongo command flag for testing. (#5676)
* Add openpype_mongo command flag for testing. * Revert back to TEST_OPENPYPE_MONGO TEST_OPENPYPE_MONGO is placeholder used in all source test sip in `input/env_vars/env_var` not a env variable itself * Fix openpype_mongo fixture Fixture decorator was missing. If value passed from command line should be used, it must come first as `env_var` fixture should already contain valid default Mongo uri. * Renamed command line argument to mongo_url --------- Co-authored-by: kalisp <petr.kalis@gmail.com>
This commit is contained in:
parent
17dbe5b718
commit
e78b6065ac
4 changed files with 33 additions and 5 deletions
|
|
@ -29,6 +29,11 @@ def pytest_addoption(parser):
|
|||
help="True - only setup test, do not run any tests"
|
||||
)
|
||||
|
||||
parser.addoption(
|
||||
"--mongo_url", action="store", default=None,
|
||||
help="Provide url of the Mongo database."
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def test_data_folder(request):
|
||||
|
|
@ -55,6 +60,11 @@ def setup_only(request):
|
|||
return request.config.getoption("--setup_only")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def mongo_url(request):
|
||||
return request.config.getoption("--mongo_url")
|
||||
|
||||
|
||||
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
||||
def pytest_runtest_makereport(item, call):
|
||||
# execute all other hooks to obtain the report object
|
||||
|
|
|
|||
|
|
@ -147,11 +147,11 @@ class ModuleUnitTest(BaseTest):
|
|||
|
||||
@pytest.fixture(scope="module")
|
||||
def db_setup(self, download_test_data, env_var, monkeypatch_session,
|
||||
request):
|
||||
request, mongo_url):
|
||||
"""Restore prepared MongoDB dumps into selected DB."""
|
||||
backup_dir = os.path.join(download_test_data, "input", "dumps")
|
||||
|
||||
uri = os.environ.get("OPENPYPE_MONGO")
|
||||
uri = mongo_url or 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