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

Commit

Permalink
#1794 - added fixtures for db connections
Browse files Browse the repository at this point in the history
  • Loading branch information
kalisp committed Sep 2, 2021
1 parent cb4c740 commit 8be9838
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions tests/lib/testing_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,33 @@


class TestCase:
"""Generic test class for testing
Implemented fixtures:
monkeypatch_session - fixture for env vars with session scope
download_test_data - tmp folder with extracted data from GDrive
env_var - sets env vars from input file
db_setup - prepares avalon AND openpype DBs for testing from
binary dumps from input data
dbcon - returns DBConnection to AvalonDB
dbcon_openpype - returns DBConnection for OpenpypeMongoDB
Not implemented:
last_workfile_path - returns path to testing workfile
"""
TEST_OPENPYPE_MONGO = "mongodb://localhost:27017"
TEST_DB_NAME = "test_db"
TEST_PROJECT_NAME = "test_project"
TEST_OPENPYPE_NAME = "test_openpype"

REPRESENTATION_ID = "60e578d0c987036c6a7b741d"

TEST_FILES = [
("1eCwPljuJeOI8A3aisfOIBKKjcmIycTEt", "test_site_operations.zip", "")
]
TEST_FILES = []

PROJECT = "test_project"
ASSET = "test_asset"
TASK = "test_task"

@pytest.fixture(scope='session')
def monkeypatch_session(self):
Expand All @@ -47,6 +63,7 @@ def download_test_data(self):
RemoteFileHandler.unzip(os.path.join(tmpdir, file_name))

yield tmpdir
print("Removing {}".format(tmpdir))
shutil.rmtree(tmpdir)

@pytest.fixture(scope="module")
Expand Down Expand Up @@ -105,4 +122,23 @@ def dbcon(self, db_setup):
"""
from avalon.api import AvalonMongoDB
dbcon = AvalonMongoDB()
dbcon.Session["AVALON_PROJECT"] = self.TEST_PROJECT_NAME
yield dbcon

@pytest.fixture(scope="module")
def dbcon_openpype(self, db_setup):
"""Provide test database connection for OP settings.
Database prepared from dumps with 'db_setup' fixture.
"""
from openpype.lib import OpenPypeMongoConnection
mongo_client = OpenPypeMongoConnection.get_mongo_client()
yield mongo_client[self.TEST_OPENPYPE_NAME]["settings"]

@pytest.fixture(scope="module")
def last_workfile_path(self, download_test_data):
raise NotImplemented

@pytest.fixture(scope="module")
def startup_scripts(self, monkeypatch_session, download_test_data):
raise NotImplemented

0 comments on commit 8be9838

Please sign in to comment.