mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
OP-2042 - added functionality to reuse existing folder for testdata
This commit is contained in:
parent
68b5078ae1
commit
d55d996f9c
2 changed files with 24 additions and 26 deletions
|
|
@ -25,7 +25,7 @@ class TestPublishInNuke(PublishTest):
|
|||
{OPENPYPE_ROOT}/.venv/Scripts/python.exe {OPENPYPE_ROOT}/start.py runtests ../tests/integration/hosts/nuke # noqa: E501
|
||||
|
||||
"""
|
||||
PERSIST = True # True - keep test_db, test_openpype, outputted test files
|
||||
PERSIST = False # True - keep test_db, test_openpype, outputted test files
|
||||
|
||||
TEST_FILES = [
|
||||
("1SUurHj2aiQ21ZIMJfGVBI2KjR8kIjBGI", "test_Nuke_publish.zip", "")
|
||||
|
|
@ -38,11 +38,12 @@ class TestPublishInNuke(PublishTest):
|
|||
|
||||
TIMEOUT = 120 # publish timeout
|
||||
|
||||
TEST_DATA_FOLDER = None # provide existing folder with test data
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def last_workfile_path(self, download_test_data):
|
||||
"""Get last_workfile_path from source data.
|
||||
|
||||
Maya expects workfile in proper folder, so copy is done first.
|
||||
"""
|
||||
log.info("log last_workfile_path")
|
||||
src_path = os.path.join(
|
||||
|
|
@ -50,17 +51,8 @@ class TestPublishInNuke(PublishTest):
|
|||
"input",
|
||||
"workfile",
|
||||
"test_project_test_asset_CompositingInNuke_v001.nk")
|
||||
dest_folder = os.path.join(download_test_data,
|
||||
self.PROJECT,
|
||||
self.ASSET,
|
||||
"work",
|
||||
self.TASK)
|
||||
os.makedirs(dest_folder)
|
||||
dest_path = os.path.join(
|
||||
dest_folder, "test_project_test_asset_CompositingInNuke_v001.nk")
|
||||
shutil.copy(src_path, dest_path)
|
||||
|
||||
yield dest_path
|
||||
yield src_path
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def startup_scripts(self, monkeypatch_session, download_test_data):
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ class ModuleUnitTest(BaseTest):
|
|||
ASSET = "test_asset"
|
||||
TASK = "test_task"
|
||||
|
||||
TEST_DATA_FOLDER = None
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def monkeypatch_session(self):
|
||||
"""Monkeypatch couldn't be used with module or session fixtures."""
|
||||
|
|
@ -55,24 +57,28 @@ class ModuleUnitTest(BaseTest):
|
|||
|
||||
@pytest.fixture(scope="module")
|
||||
def download_test_data(self):
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
for test_file in self.TEST_FILES:
|
||||
file_id, file_name, md5 = test_file
|
||||
if self.TEST_DATA_FOLDER:
|
||||
print("Using existing folder {}".format(self.TEST_DATA_FOLDER))
|
||||
yield self.TEST_DATA_FOLDER
|
||||
else:
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
for test_file in self.TEST_FILES:
|
||||
file_id, file_name, md5 = test_file
|
||||
|
||||
f_name, ext = os.path.splitext(file_name)
|
||||
f_name, ext = os.path.splitext(file_name)
|
||||
|
||||
RemoteFileHandler.download_file_from_google_drive(file_id,
|
||||
str(tmpdir),
|
||||
file_name)
|
||||
RemoteFileHandler.download_file_from_google_drive(file_id,
|
||||
str(tmpdir),
|
||||
file_name)
|
||||
|
||||
if ext.lstrip('.') in RemoteFileHandler.IMPLEMENTED_ZIP_FORMATS:
|
||||
RemoteFileHandler.unzip(os.path.join(tmpdir, file_name))
|
||||
print("Temporary folder created:: {}".format(tmpdir))
|
||||
yield tmpdir
|
||||
if ext.lstrip('.') in RemoteFileHandler.IMPLEMENTED_ZIP_FORMATS: #noqa E501
|
||||
RemoteFileHandler.unzip(os.path.join(tmpdir, file_name))
|
||||
print("Temporary folder created:: {}".format(tmpdir))
|
||||
yield tmpdir
|
||||
|
||||
if not self.PERSIST:
|
||||
print("Removing {}".format(tmpdir))
|
||||
shutil.rmtree(tmpdir)
|
||||
if not self.PERSIST:
|
||||
print("Removing {}".format(tmpdir))
|
||||
shutil.rmtree(tmpdir)
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def env_var(self, monkeypatch_session, download_test_data):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue