Added setup_only to tests (#4591)

Allows to download test zip, unzip and restore DB in preparation for new test.
This commit is contained in:
Petr Kalis 2023-03-13 15:37:23 +01:00 committed by GitHub
parent e68933ced8
commit ff19ae0385
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 6 deletions

View file

@ -367,11 +367,15 @@ def run(script):
"--timeout",
help="Provide specific timeout value for test case",
default=None)
@click.option("-so",
"--setup_only",
help="Only create dbs, do not run tests",
default=None)
def runtests(folder, mark, pyargs, test_data_folder, persist, app_variant,
timeout):
timeout, setup_only):
"""Run all automatic tests after proper initialization via start.py"""
PypeCommands().run_tests(folder, mark, pyargs, test_data_folder,
persist, app_variant, timeout)
persist, app_variant, timeout, setup_only)
@main.command()

View file

@ -270,7 +270,7 @@ class PypeCommands:
pass
def run_tests(self, folder, mark, pyargs,
test_data_folder, persist, app_variant, timeout):
test_data_folder, persist, app_variant, timeout, setup_only):
"""
Runs tests from 'folder'
@ -311,6 +311,9 @@ class PypeCommands:
if timeout:
args.extend(["--timeout", timeout])
if setup_only:
args.extend(["--setup_only", setup_only])
print("run_tests args: {}".format(args))
import pytest
pytest.main(args)

View file

@ -24,6 +24,11 @@ def pytest_addoption(parser):
help="Overwrite default timeout"
)
parser.addoption(
"--setup_only", action="store", default=None,
help="True - only setup test, do not run any tests"
)
@pytest.fixture(scope="module")
def test_data_folder(request):
@ -45,6 +50,11 @@ def timeout(request):
return request.config.getoption("--timeout")
@pytest.fixture(scope="module")
def setup_only(request):
return request.config.getoption("--setup_only")
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
# execute all other hooks to obtain the report object

View file

@ -243,6 +243,8 @@ class PublishTest(ModuleUnitTest):
PERSIST = True # True - keep test_db, test_openpype, outputted test files
TEST_DATA_FOLDER = None # use specific folder of unzipped test file
SETUP_ONLY = False
@pytest.fixture(scope="module")
def app_name(self, app_variant):
"""Returns calculated value for ApplicationManager. Eg.(nuke/12-2)"""
@ -286,8 +288,13 @@ class PublishTest(ModuleUnitTest):
@pytest.fixture(scope="module")
def launched_app(self, dbcon, download_test_data, last_workfile_path,
startup_scripts, app_args, app_name, output_folder_url):
startup_scripts, app_args, app_name, output_folder_url,
setup_only):
"""Launch host app"""
if setup_only or self.SETUP_ONLY:
print("Creating only setup for test, not launching app")
yield
return
# set schema - for integrate_new
from openpype import PACKAGE_DIR
# Path to OpenPype's schema
@ -316,8 +323,12 @@ class PublishTest(ModuleUnitTest):
@pytest.fixture(scope="module")
def publish_finished(self, dbcon, launched_app, download_test_data,
timeout):
timeout, setup_only):
"""Dummy fixture waiting for publish to finish"""
if setup_only or self.SETUP_ONLY:
print("Creating only setup for test, not launching app")
yield False
return
import time
time_start = time.time()
timeout = timeout or self.TIMEOUT
@ -334,11 +345,16 @@ class PublishTest(ModuleUnitTest):
def test_folder_structure_same(self, dbcon, publish_finished,
download_test_data, output_folder_url,
skip_compare_folders):
skip_compare_folders,
setup_only):
"""Check if expected and published subfolders contain same files.
Compares only presence, not size nor content!
"""
if setup_only or self.SETUP_ONLY:
print("Creating only setup for test, not launching app")
return
published_dir_base = output_folder_url
expected_dir_base = os.path.join(download_test_data,
"expected")