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:
Toke Jepsen 2023-10-03 18:18:02 +01:00 committed by GitHub
parent 17dbe5b718
commit e78b6065ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 5 deletions

View file

@ -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

View file

@ -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,