From d0a4293b9d12e59b59bac0c9845f45fc84839ff3 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 6 Sep 2021 18:42:34 +0200 Subject: [PATCH] #1784 - added howto create new publishing test --- tests/integration/README.md | 31 ++++++++++++++++++ .../hosts/maya/test_publish_in_maya.py | 4 ++- tests/lib/testing_classes.py | 20 +++++++---- tests/resources/test_data.zip | Bin 0 -> 7350 bytes 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 tests/resources/test_data.zip diff --git a/tests/integration/README.md b/tests/integration/README.md index 00d8a4c10d..81c07ec50c 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -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 \ No newline at end of file diff --git a/tests/integration/hosts/maya/test_publish_in_maya.py b/tests/integration/hosts/maya/test_publish_in_maya.py index 86b26ba5e5..b9c63651f1 100644 --- a/tests/integration/hosts/maya/test_publish_in_maya.py +++ b/tests/integration/hosts/maya/test_publish_in_maya.py @@ -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, diff --git a/tests/lib/testing_classes.py b/tests/lib/testing_classes.py index 6c7bebd469..6cd3c10d3e 100644 --- a/tests/lib/testing_classes.py +++ b/tests/lib/testing_classes.py @@ -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() diff --git a/tests/resources/test_data.zip b/tests/resources/test_data.zip new file mode 100644 index 0000000000000000000000000000000000000000..0faab86b37d5c7d1224e8a92cca766ed80536718 GIT binary patch literal 7350 zcmb7I1z1$u8XdZE=nm;_LAtv}N|27ByE`OAU}#VpL68msX(XiuK^hd0ZV(Uz^$nNj zMY-H}@7sKbGc(`6*4g{t|K98D1yY2A#|6Lw008_XI(6vn&xQ*9 z8Ao(24(GQxu%{!~)D>*@3xMhx0Qeig%HGk<^_OVuYti^OM4P$UIlBB048`AK92~*+ zj$V%7Kf%ZV~5Z-Q;;l_Z{v#(ni-;f;D+uA>_3_4;u= zI>y9!s)`ru+DgUns)GsnWtapLep49acxd0{2Wk0TWj4*{imJI2Uk69VWvnWFZM?j| ze%qMx8u;{#E>lYWvOov!cI4*YZd;S;@PlY*>`z9zUMyVrD>_u zk;FT^8hqleVs%_zQL(~>Hsp7;rFNAStI;$Q-g4g}F+&Z$Wt|dOA(V#f@d()?^JueI z2U)cFn;&KHmxB*NZdS^iDfzlzBFgn{(~=Rb+ClY_syq@ zw+DCa2k9DL|6G@sbzJI8MOF;0-xKJ?`7i6(4(w`tvBcS|p#=?&>BoG?0hIm$UQ{tb zO$2FgwnIdX(AP~lAbGT67z!sIx^qt}npX#!QxNn-tt?~<2x6Od?}-azkmC>@k(f4A zwcy+(%^;wIk0qB&dBOuG65f_auz@AZ`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