mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
#1784 - added howto create new publishing test
This commit is contained in:
parent
124429c5ee
commit
d0a4293b9d
4 changed files with 48 additions and 7 deletions
|
|
@ -4,3 +4,34 @@ Contains end-to-end tests for automatic testing of OP.
|
|||
|
||||
Should run headless publish on all hosts to check basic publish use cases automatically
|
||||
to limit regression issues.
|
||||
|
||||
How to create test for publishing from host
|
||||
------------------------------------------
|
||||
- Extend PublishTest
|
||||
- Use `resources\test_data.zip` skeleton file as a template for testing input data
|
||||
- Put workfile into `test_data.zip/input/workfile`
|
||||
- If you require other than base DB dumps provide them to `test_data.zip/input/dumps`
|
||||
-- (Check commented code in `db_handler.py` how to dump specific DB. Currently all collections will be dumped.)
|
||||
- Implement `last_workfile_path`
|
||||
- `startup_scripts` - must contain pointing host to startup script saved into `test_data.zip/input/startup`
|
||||
-- Script must contain something like
|
||||
```
|
||||
import openpype
|
||||
from avalon import api, HOST
|
||||
|
||||
api.install(HOST)
|
||||
pyblish.util.publish()
|
||||
|
||||
EXIT_APP (command to exit host)
|
||||
```
|
||||
(Install and publish methods must be triggered only AFTER host app is fully initialized!)
|
||||
- Zip `test_data.zip`, named it with descriptive name, upload it to Google Drive, right click - `Get link`, copy hash id
|
||||
- Put this hash id and zip file name into TEST_FILES [(HASH_ID, FILE_NAME, MD5_OPTIONAL)]. If you want to check MD5 of downloaded
|
||||
file, provide md5 value of zipped file.
|
||||
- Implement any assert checks you need in extended class
|
||||
- Run test class manually (via Pycharm or pytest runner (TODO))
|
||||
- If you want test to compare expected files to published one, set PERSIST to True, run test manually
|
||||
-- Locate temporary `publish` subfolder of temporary folder (found in debugging console log)
|
||||
-- Copy whole folder content into .zip file into `expected` subfolder
|
||||
-- By default tests are comparing only structure of `expected` and published format (eg. if you want to save space, replace published files with empty files, but with expected names!)
|
||||
-- Zip and upload again, change PERSIST to False
|
||||
|
|
@ -20,6 +20,8 @@ class TestPublishInMaya(PublishTest):
|
|||
Checks tmp folder if all expected files were published.
|
||||
|
||||
"""
|
||||
PERSIST = True
|
||||
|
||||
TEST_FILES = [
|
||||
("1pOwjA_VVBc6ooTZyFxtAwLS2KZHaBlkY", "test_maya_publish.zip", "")
|
||||
]
|
||||
|
|
@ -39,7 +41,7 @@ class TestPublishInMaya(PublishTest):
|
|||
"""
|
||||
src_path = os.path.join(download_test_data,
|
||||
"input",
|
||||
"data",
|
||||
"workfile",
|
||||
"test_project_test_asset_TestTask_v001.mb")
|
||||
dest_folder = os.path.join(download_test_data,
|
||||
self.PROJECT,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ class BaseTest:
|
|||
class ModuleUnitTest(BaseTest):
|
||||
"""Generic test class for testing modules
|
||||
|
||||
Use PERSIST==True to keep temporary folder and DB prepared for
|
||||
debugging or preparation of test files.
|
||||
|
||||
Implemented fixtures:
|
||||
monkeypatch_session - fixture for env vars with session scope
|
||||
download_test_data - tmp folder with extracted data from GDrive
|
||||
|
|
@ -29,6 +32,8 @@ class ModuleUnitTest(BaseTest):
|
|||
dbcon_openpype - returns DBConnection for OpenpypeMongoDB
|
||||
|
||||
"""
|
||||
PERSIST = False # True to not purge temporary folder nor test DB
|
||||
|
||||
TEST_OPENPYPE_MONGO = "mongodb://localhost:27017"
|
||||
TEST_DB_NAME = "test_db"
|
||||
TEST_PROJECT_NAME = "test_project"
|
||||
|
|
@ -62,10 +67,12 @@ class ModuleUnitTest(BaseTest):
|
|||
|
||||
if ext.lstrip('.') in RemoteFileHandler.IMPLEMENTED_ZIP_FORMATS:
|
||||
RemoteFileHandler.unzip(os.path.join(tmpdir, file_name))
|
||||
|
||||
print("Temporary folder created:: {}".format(tmpdir))
|
||||
yield tmpdir
|
||||
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):
|
||||
|
|
@ -112,8 +119,9 @@ class ModuleUnitTest(BaseTest):
|
|||
|
||||
yield db_handler
|
||||
|
||||
db_handler.teardown(self.TEST_DB_NAME)
|
||||
db_handler.teardown(self.TEST_OPENPYPE_NAME)
|
||||
if not self.PERSIST:
|
||||
db_handler.teardown(self.TEST_DB_NAME)
|
||||
db_handler.teardown(self.TEST_OPENPYPE_NAME)
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def dbcon(self, db_setup):
|
||||
|
|
@ -213,7 +221,7 @@ class PublishTest(ModuleUnitTest):
|
|||
yield application_manager.launch(self.APP_NAME, **data)
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def publish_finished(self, dbcon, launched_app):
|
||||
def publish_finished(self, dbcon, launched_app, download_test_data):
|
||||
"""Dummy fixture waiting for publish to finish"""
|
||||
import time
|
||||
time_start = time.time()
|
||||
|
|
|
|||
BIN
tests/resources/test_data.zip
Normal file
BIN
tests/resources/test_data.zip
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue