From d35ea96bd08e099adae7a52da5f0585e3d8a0760 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 24 Oct 2022 11:52:08 +0200 Subject: [PATCH] OP-3426 - added filtering of published folders from comparing Some files or folders are dynamically created and cannot be part of comparing of published and expected folder structure. (Example is Logs in AE from DL) --- tests/integration/hosts/aftereffects/lib.py | 5 +++++ tests/integration/hosts/maya/lib.py | 4 ++++ tests/integration/hosts/nuke/lib.py | 3 +++ tests/integration/hosts/photoshop/lib.py | 4 ++++ tests/lib/testing_classes.py | 23 +++++++++++++++++---- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/tests/integration/hosts/aftereffects/lib.py b/tests/integration/hosts/aftereffects/lib.py index 541103cb2e..3fb1fa18ce 100644 --- a/tests/integration/hosts/aftereffects/lib.py +++ b/tests/integration/hosts/aftereffects/lib.py @@ -37,6 +37,11 @@ class AEHostFixtures(HostFixtures): """Points Maya to userSetup file from input data""" pass + @pytest.fixture(scope="module") + def skip_compare_folders(self): + # skip folder that contain "Logs", these come only from Deadline + return ["Logs"] + class AELocalPublishTestClass(AEHostFixtures, PublishTest): """Testing class for local publishes.""" diff --git a/tests/integration/hosts/maya/lib.py b/tests/integration/hosts/maya/lib.py index 1411ccca5f..e7480e25fa 100644 --- a/tests/integration/hosts/maya/lib.py +++ b/tests/integration/hosts/maya/lib.py @@ -44,6 +44,10 @@ class MayaHostFixtures(HostFixtures): os.pathsep, original_pythonpath)) + @pytest.fixture(scope="module") + def skip_compare_folders(self): + yield [] + class MayaLocalPublishTestClass(MayaHostFixtures, PublishTest): """Testing class for local publishes.""" diff --git a/tests/integration/hosts/nuke/lib.py b/tests/integration/hosts/nuke/lib.py index 564a5d3b88..8e97cd6fe4 100644 --- a/tests/integration/hosts/nuke/lib.py +++ b/tests/integration/hosts/nuke/lib.py @@ -56,6 +56,9 @@ class NukeHostFixtures(HostFixtures): os.pathsep, original_nuke_path)) + @pytest.fixture(scope="module") + def skip_compare_folders(self): + yield [] class NukeLocalPublishTestClass(NukeHostFixtures, PublishTest): """Testing class for local publishes.""" diff --git a/tests/integration/hosts/photoshop/lib.py b/tests/integration/hosts/photoshop/lib.py index 16ef2d3ae6..23ae79434e 100644 --- a/tests/integration/hosts/photoshop/lib.py +++ b/tests/integration/hosts/photoshop/lib.py @@ -32,3 +32,7 @@ class PhotoshopTestClass(HostFixtures): def startup_scripts(self, monkeypatch_session, download_test_data): """Points Maya to userSetup file from input data""" pass + + @pytest.fixture(scope="module") + def skip_compare_folders(self): + yield [] \ No newline at end of file diff --git a/tests/lib/testing_classes.py b/tests/lib/testing_classes.py index e4f816f4d0..8aaeb4304b 100644 --- a/tests/lib/testing_classes.py +++ b/tests/lib/testing_classes.py @@ -9,6 +9,7 @@ import shutil import glob import platform import requests +import re from tests.lib.db_handler import DBHandler from common.openpype_common.distribution.file_handler import RemoteFileHandler @@ -316,7 +317,8 @@ class PublishTest(ModuleUnitTest): yield True def test_folder_structure_same(self, dbcon, publish_finished, - download_test_data, output_folder_url): + download_test_data, output_folder_url, + skip_compare_folders): """Check if expected and published subfolders contain same files. Compares only presence, not size nor content! @@ -334,9 +336,17 @@ class PublishTest(ModuleUnitTest): glob.glob(expected_dir_base + "\\**", recursive=True) if f != expected_dir_base and os.path.exists(f)) - not_matched = expected.symmetric_difference(published) - assert not not_matched, "Missing {} files".format( - "\n".join(sorted(not_matched))) + filtered_published = set() + for pub_path in published: + for val in skip_compare_folders: + if not re.search(val, pub_path): + filtered_published.add(pub_path) + + not_matched = expected.symmetric_difference(filtered_published) + if not_matched: + self.failed = True + raise AssertionError("Missing {} files".format( + "\n".join(sorted(not_matched)))) class DeadlinePublishTest(PublishTest): @@ -419,3 +429,8 @@ class HostFixtures(): def startup_scripts(self, monkeypatch_session, download_test_data): """"Adds init scripts (like userSetup) to expected location""" raise NotImplementedError + + @pytest.fixture(scope="module") + def skip_compare_folders(self): + """Use list of regexs to filter out published folders from comparing""" + raise NotImplementedError