From 3860fe36926aad704cf6d0ef66c89542e2acf922 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 23 Mar 2023 18:09:11 +0100 Subject: [PATCH 01/15] OP-3951 - updated validator to use special pattern Handles numbers (version, instance number) in file names. --- .../publish/validate_sequence_frames.py | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/openpype/plugins/publish/validate_sequence_frames.py b/openpype/plugins/publish/validate_sequence_frames.py index f03229da22..c932c0e779 100644 --- a/openpype/plugins/publish/validate_sequence_frames.py +++ b/openpype/plugins/publish/validate_sequence_frames.py @@ -1,3 +1,8 @@ +import os.path + +import clique +import re + import pyblish.api @@ -7,6 +12,11 @@ class ValidateSequenceFrames(pyblish.api.InstancePlugin): The files found in the folder are checked against the startFrame and endFrame of the instance. If the first or last file is not corresponding with the first or last frame it is flagged as invalid. + + Used regular expression pattern handles numbers in the file names + (eg "Main_beauty.v001.1001.exr", "Main_beauty_v001.1001.exr", + "Main_beauty.1001.1001.exr") but not numbers behind frames (eg. + "Main_beauty.1001.v001.exr") """ order = pyblish.api.ValidatorOrder @@ -15,20 +25,31 @@ class ValidateSequenceFrames(pyblish.api.InstancePlugin): hosts = ["shell"] def process(self, instance): + representations = instance.data.get("representations") + for repr in representations: + if isinstance(repr["files"], str): + repr["files"] = [repr["files"]] - collection = instance[0] - self.log.info(collection) + _, ext = os.path.splitext(repr["files"][0]) + pattern = r"\D?(?P(?P0*)\d+){}$".format( + re.escape(ext)) + patterns = [pattern] - frames = list(collection.indexes) + collections, remainder = clique.assemble( + repr["files"], minimum_items=1, patterns=patterns) - current_range = (frames[0], frames[-1]) - required_range = (instance.data["frameStart"], - instance.data["frameEnd"]) + assert not remainder, "Must not have remainder" + assert len(collections) == 1, "Must detect single collection" + collection = collections[0] + frames = list(collection.indexes) - if current_range != required_range: - raise ValueError("Invalid frame range: {0} - " - "expected: {1}".format(current_range, - required_range)) + current_range = (frames[0], frames[-1]) + required_range = (instance.data["frameStart"], + instance.data["frameEnd"]) - missing = collection.holes().indexes - assert not missing, "Missing frames: %s" % (missing,) + if current_range != required_range: + raise ValueError(f"Invalid frame range: {current_range} - " + f"expected: {required_range}") + + missing = collection.holes().indexes + assert not missing, "Missing frames: %s" % (missing,) From e8f9c130bbb7b805f6ea68a3bbc37d81168d5893 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 23 Mar 2023 18:11:28 +0100 Subject: [PATCH 02/15] OP-3951 - merged global validator and unreal one Both should do same thing. Combination of host and family should be safe. --- .../publish/validate_sequence_frames.py | 41 ------------------- .../publish/validate_sequence_frames.py | 4 +- 2 files changed, 2 insertions(+), 43 deletions(-) delete mode 100644 openpype/hosts/unreal/plugins/publish/validate_sequence_frames.py diff --git a/openpype/hosts/unreal/plugins/publish/validate_sequence_frames.py b/openpype/hosts/unreal/plugins/publish/validate_sequence_frames.py deleted file mode 100644 index 87f1338ee8..0000000000 --- a/openpype/hosts/unreal/plugins/publish/validate_sequence_frames.py +++ /dev/null @@ -1,41 +0,0 @@ -import clique - -import pyblish.api - - -class ValidateSequenceFrames(pyblish.api.InstancePlugin): - """Ensure the sequence of frames is complete - - The files found in the folder are checked against the frameStart and - frameEnd of the instance. If the first or last file is not - corresponding with the first or last frame it is flagged as invalid. - """ - - order = pyblish.api.ValidatorOrder - label = "Validate Sequence Frames" - families = ["render"] - hosts = ["unreal"] - optional = True - - def process(self, instance): - representations = instance.data.get("representations") - for repr in representations: - patterns = [clique.PATTERNS["frames"]] - collections, remainder = clique.assemble( - repr["files"], minimum_items=1, patterns=patterns) - - assert not remainder, "Must not have remainder" - assert len(collections) == 1, "Must detect single collection" - collection = collections[0] - frames = list(collection.indexes) - - current_range = (frames[0], frames[-1]) - required_range = (instance.data["frameStart"], - instance.data["frameEnd"]) - - if current_range != required_range: - raise ValueError(f"Invalid frame range: {current_range} - " - f"expected: {required_range}") - - missing = collection.holes().indexes - assert not missing, "Missing frames: %s" % (missing,) diff --git a/openpype/plugins/publish/validate_sequence_frames.py b/openpype/plugins/publish/validate_sequence_frames.py index c932c0e779..56641fbf57 100644 --- a/openpype/plugins/publish/validate_sequence_frames.py +++ b/openpype/plugins/publish/validate_sequence_frames.py @@ -21,8 +21,8 @@ class ValidateSequenceFrames(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrder label = "Validate Sequence Frames" - families = ["imagesequence"] - hosts = ["shell"] + families = ["imagesequence", "render"] + hosts = ["shell", "unreal"] def process(self, instance): representations = instance.data.get("representations") From 0648271ec784824fef1c7ffe373d0ae1034b9ec6 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 23 Mar 2023 18:15:11 +0100 Subject: [PATCH 03/15] OP-3951 - added tests for validate_sequence_frames Introduced conftest with dummy environment for basic tests --- tests/unit/openpype/conftest.py | 38 +++++ .../publish/test_validate_sequence_frames.py | 143 ++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 tests/unit/openpype/conftest.py create mode 100644 tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py diff --git a/tests/unit/openpype/conftest.py b/tests/unit/openpype/conftest.py new file mode 100644 index 0000000000..e5355a3120 --- /dev/null +++ b/tests/unit/openpype/conftest.py @@ -0,0 +1,38 @@ +"""Dummy environment that allows importing Openpype modules and run +tests in parent folder and all subfolders manually from IDE. + +This should not get triggered if the tests are running from `runtests` as it +is expected there that environment is handled by OP itself. + +This environment should be enough to run simple `BaseTest` where no +external preparation is necessary (eg. no prepared DB, no source files). +These tests might be enough to import and run simple pyblish plugins to +validate logic. + +Please be aware that these tests might use values in real databases, so use +`BaseTest` only for logic without side effects or special configuration. For +these there is `tests.lib.testing_classes.ModuleUnitTest` which would setup +proper test DB (but it requires `mongorestore` on the sys.path) + +If pyblish plugins require any host dependent communication, it would need + to be mocked. + +This setting of env vars is necessary to run before any imports of OP code! +(This is why it is in `conftest.py` file.) +If your test requires any additional env var, copy this file to folder of your +test, it should only that folder. +""" + +import os + + +if not os.environ.get("IS_TEST"): # running tests from cmd or CI + os.environ["AVALON_MONGO"] = "mongodb://localhost:27017" + os.environ["OPENPYPE_MONGO"] = "mongodb://localhost:27017" + os.environ["AVALON_DB"] = "avalon" + os.environ["OPENPYPE_DATABASE_NAME"] = "avalon" + os.environ["AVALON_TIMEOUT"] = '3000' + os.environ["OPENPYPE_DEBUG"] = "3" + os.environ["AVALON_CONFIG"] = "pype" + os.environ["AVALON_ASSET"] = "test_asset" + os.environ["AVALON_PROJECT"] = "test_project" diff --git a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py new file mode 100644 index 0000000000..5580621cfb --- /dev/null +++ b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py @@ -0,0 +1,143 @@ + + +"""Test Publish_plugins pipeline publish modul, tests API methods + + File: + creates temporary directory and downloads .zip file from GDrive + unzips .zip file + uses content of .zip file (MongoDB's dumps) to import to new databases + with use of 'monkeypatch_session' modifies required env vars + temporarily + runs battery of tests checking that site operation for Sync Server + module are working + removes temporary folder + removes temporary databases (?) +""" +import pytest +import logging + +from pyblish.api import Instance as PyblishInstance + +from tests.lib.testing_classes import BaseTest +from openpype.plugins.publish.validate_sequence_frames import ( + ValidateSequenceFrames +) + +log = logging.getLogger(__name__) + + +class TestValidateSequenceFrames(BaseTest): + """ Testing ValidateSequenceFrames plugin + + """ + + @pytest.fixture + def instance(self): + + class Instance(PyblishInstance): + data = { + "frameStart": 1001, + "frameEnd": 1001, + "representations": [] + } + yield Instance + + @pytest.fixture(scope="module") + def plugin(self): + plugin = ValidateSequenceFrames() + plugin.log = log + + yield plugin + + def test_validate_sequence_frames_single_frame(self, instance, plugin): + representations = [ + { + "ext": "exr", + "files": "Main_beauty.1001.exr", + } + ] + instance.data["representations"] = representations + + plugin.process(instance) + + @pytest.mark.parametrize("files", + ["Main_beauty.v001.1001.exr", + "Main_beauty_v001.1001.exr", + "Main_beauty.1001.1001.exr"]) + def test_validate_sequence_frames_single_frame_name(self, instance, + plugin, + files): + # tests for names with number inside, caused clique failure before + representations = [ + { + "ext": "exr", + "files": files, + } + ] + instance.data["representations"] = representations + + plugin.process(instance) + + @pytest.mark.parametrize("files", + ["Main_beauty.1001.v001.exr"]) + def test_validate_sequence_frames_single_frame_wrong_name(self, instance, + plugin, + files): + # tests for names with number inside, caused clique failure before + representations = [ + { + "ext": "exr", + "files": files, + } + ] + instance.data["representations"] = representations + + with pytest.raises(ValueError) as excinfo: + plugin.process(instance) + assert ("Invalid frame range: (1, 1) - expected: (1001, 1001)" in + str(excinfo.value)) + + def test_validate_sequence_frames_multi_frame(self, instance, plugin): + representations = [ + { + "ext": "exr", + "files": ["Main_beauty.1001.exr", "Main_beauty.1002.exr", + "Main_beauty.1003.exr"] + } + ] + instance.data["representations"] = representations + instance.data["frameEnd"] = 1003 + + plugin.process(instance) + + def test_validate_sequence_frames_multi_frame_missing(self, instance, + plugin): + representations = [ + { + "ext": "exr", + "files": ["Main_beauty.1001.exr", "Main_beauty.1002.exr"] + } + ] + instance.data["representations"] = representations + instance.data["frameEnd"] = 1003 + + with pytest.raises(ValueError) as excinfo: + plugin.process(instance) + assert ("Invalid frame range: (1001, 1002) - expected: (1001, 1003)" in + str(excinfo.value)) + + def test_validate_sequence_frames_multi_frame_hole(self, instance, plugin): + representations = [ + { + "ext": "exr", + "files": ["Main_beauty.1001.exr", "Main_beauty.1003.exr"] + } + ] + instance.data["representations"] = representations + instance.data["frameEnd"] = 1003 + + with pytest.raises(AssertionError) as excinfo: + plugin.process(instance) + assert ("Missing frames: [1002]" in str(excinfo.value)) + +test_case = TestValidateSequenceFrames() From 87fe237aa718d5e387b288bb7ad430d586712ec6 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 24 Mar 2023 11:14:51 +0100 Subject: [PATCH 04/15] OP-3951 - fix - do not change files in place Integrator depends that single files is not in list. --- openpype/plugins/publish/validate_sequence_frames.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openpype/plugins/publish/validate_sequence_frames.py b/openpype/plugins/publish/validate_sequence_frames.py index 56641fbf57..98df259cc8 100644 --- a/openpype/plugins/publish/validate_sequence_frames.py +++ b/openpype/plugins/publish/validate_sequence_frames.py @@ -27,16 +27,17 @@ class ValidateSequenceFrames(pyblish.api.InstancePlugin): def process(self, instance): representations = instance.data.get("representations") for repr in representations: - if isinstance(repr["files"], str): - repr["files"] = [repr["files"]] + repr_files = repr["files"] + if isinstance(repr_files, str): + repr_files = [repr_files] - _, ext = os.path.splitext(repr["files"][0]) + _, ext = os.path.splitext(repr_files[0]) pattern = r"\D?(?P(?P0*)\d+){}$".format( re.escape(ext)) patterns = [pattern] collections, remainder = clique.assemble( - repr["files"], minimum_items=1, patterns=patterns) + repr_files, minimum_items=1, patterns=patterns) assert not remainder, "Must not have remainder" assert len(collections) == 1, "Must detect single collection" From f95007b660c9d573d9c41b4ec6169e022434daed Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 24 Mar 2023 11:15:27 +0100 Subject: [PATCH 05/15] OP-3951 - Hound --- .../openpype/plugins/publish/test_validate_sequence_frames.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py index 5580621cfb..8e690f4f65 100644 --- a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py +++ b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py @@ -124,7 +124,7 @@ class TestValidateSequenceFrames(BaseTest): with pytest.raises(ValueError) as excinfo: plugin.process(instance) assert ("Invalid frame range: (1001, 1002) - expected: (1001, 1003)" in - str(excinfo.value)) + str(excinfo.value)) def test_validate_sequence_frames_multi_frame_hole(self, instance, plugin): representations = [ @@ -140,4 +140,5 @@ class TestValidateSequenceFrames(BaseTest): plugin.process(instance) assert ("Missing frames: [1002]" in str(excinfo.value)) + test_case = TestValidateSequenceFrames() From 30916962c8bc0f6fbfb557c286014efe62065bd2 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 24 Mar 2023 12:34:23 +0100 Subject: [PATCH 06/15] OP-3951 - refactor Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- openpype/plugins/publish/validate_sequence_frames.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openpype/plugins/publish/validate_sequence_frames.py b/openpype/plugins/publish/validate_sequence_frames.py index 98df259cc8..409d9ac17e 100644 --- a/openpype/plugins/publish/validate_sequence_frames.py +++ b/openpype/plugins/publish/validate_sequence_frames.py @@ -26,6 +26,8 @@ class ValidateSequenceFrames(pyblish.api.InstancePlugin): def process(self, instance): representations = instance.data.get("representations") + if not representations: + return for repr in representations: repr_files = repr["files"] if isinstance(repr_files, str): From 94ceba790edf1cb4c8d04f9ed67ab518f6722455 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Fri, 24 Mar 2023 16:49:43 +0100 Subject: [PATCH 07/15] OP-3951 - updated tests --- .../publish/test_validate_sequence_frames.py | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py index 8e690f4f65..232557b76d 100644 --- a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py +++ b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py @@ -63,7 +63,8 @@ class TestValidateSequenceFrames(BaseTest): @pytest.mark.parametrize("files", ["Main_beauty.v001.1001.exr", "Main_beauty_v001.1001.exr", - "Main_beauty.1001.1001.exr"]) + "Main_beauty.1001.1001.exr", + "Main_beauty_v001_1001.exr"]) def test_validate_sequence_frames_single_frame_name(self, instance, plugin, files): @@ -97,6 +98,24 @@ class TestValidateSequenceFrames(BaseTest): assert ("Invalid frame range: (1, 1) - expected: (1001, 1001)" in str(excinfo.value)) + @pytest.mark.parametrize("files", + ["Main_beauty.1001.v001.ass.gz"]) + def test_validate_sequence_frames_single_frame_possible_wrong_name(self, + instance, plugin, files): + # currently pattern fails on extensions with dots + representations = [ + { + "ext": "exr", + "files": files, + } + ] + instance.data["representations"] = representations + + with pytest.raises(AssertionError) as excinfo: + plugin.process(instance) + assert ("Must not have remainder" in + str(excinfo.value)) + def test_validate_sequence_frames_multi_frame(self, instance, plugin): representations = [ { From 93d98c3f9c48da9477cd6ac7ffda186b57a202b8 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 27 Mar 2023 16:55:19 +0200 Subject: [PATCH 08/15] OP-3951 - use ext on representation Without it ass.gz files won't work --- .../publish/validate_sequence_frames.py | 6 ++++- .../publish/test_validate_sequence_frames.py | 22 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/openpype/plugins/publish/validate_sequence_frames.py b/openpype/plugins/publish/validate_sequence_frames.py index 409d9ac17e..a804a6d9dd 100644 --- a/openpype/plugins/publish/validate_sequence_frames.py +++ b/openpype/plugins/publish/validate_sequence_frames.py @@ -33,7 +33,11 @@ class ValidateSequenceFrames(pyblish.api.InstancePlugin): if isinstance(repr_files, str): repr_files = [repr_files] - _, ext = os.path.splitext(repr_files[0]) + ext = repr.get("ext") + if not ext: + _, ext = os.path.splitext(repr_files[0]) + elif not ext.startswith("."): + ext = ".{}".format(ext) pattern = r"\D?(?P(?P0*)\d+){}$".format( re.escape(ext)) patterns = [pattern] diff --git a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py index 232557b76d..e1facdc37b 100644 --- a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py +++ b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py @@ -99,13 +99,12 @@ class TestValidateSequenceFrames(BaseTest): str(excinfo.value)) @pytest.mark.parametrize("files", - ["Main_beauty.1001.v001.ass.gz"]) - def test_validate_sequence_frames_single_frame_possible_wrong_name(self, - instance, plugin, files): + ["Main_beauty.v001.1001.ass.gz"]) + def test_validate_sequence_frames_single_frame_possible_wrong_name( + self, instance, plugin, files): # currently pattern fails on extensions with dots representations = [ { - "ext": "exr", "files": files, } ] @@ -116,6 +115,21 @@ class TestValidateSequenceFrames(BaseTest): assert ("Must not have remainder" in str(excinfo.value)) + @pytest.mark.parametrize("files", + ["Main_beauty.v001.1001.ass.gz"]) + def test_validate_sequence_frames_single_frame_correct_ext( + self, instance, plugin, files): + # currently pattern fails on extensions with dots + representations = [ + { + "ext": "ass.gz", + "files": files, + } + ] + instance.data["representations"] = representations + + plugin.process(instance) + def test_validate_sequence_frames_multi_frame(self, instance, plugin): representations = [ { From c5172b74101dda2be4a797c0bc61056dfa134569 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 29 Mar 2023 13:17:24 +0200 Subject: [PATCH 09/15] OP-3951 - update imports Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- openpype/plugins/publish/validate_sequence_frames.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openpype/plugins/publish/validate_sequence_frames.py b/openpype/plugins/publish/validate_sequence_frames.py index a804a6d9dd..db71f2e23c 100644 --- a/openpype/plugins/publish/validate_sequence_frames.py +++ b/openpype/plugins/publish/validate_sequence_frames.py @@ -1,8 +1,7 @@ -import os.path - -import clique +import os import re +import clique import pyblish.api From 36328f8b1abbb03051795646bec8ceed5d78a874 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 29 Mar 2023 13:18:07 +0200 Subject: [PATCH 10/15] OP-3951 - removed unnecessary key Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- tests/unit/openpype/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/openpype/conftest.py b/tests/unit/openpype/conftest.py index e5355a3120..220ec3ba86 100644 --- a/tests/unit/openpype/conftest.py +++ b/tests/unit/openpype/conftest.py @@ -33,6 +33,5 @@ if not os.environ.get("IS_TEST"): # running tests from cmd or CI os.environ["OPENPYPE_DATABASE_NAME"] = "avalon" os.environ["AVALON_TIMEOUT"] = '3000' os.environ["OPENPYPE_DEBUG"] = "3" - os.environ["AVALON_CONFIG"] = "pype" os.environ["AVALON_ASSET"] = "test_asset" os.environ["AVALON_PROJECT"] = "test_project" From e2546e5547b10d085ff6b57375355361e8bda5f7 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 29 Mar 2023 13:18:37 +0200 Subject: [PATCH 11/15] OP-3951 - removed unnecessary key Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- tests/unit/openpype/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/openpype/conftest.py b/tests/unit/openpype/conftest.py index 220ec3ba86..0bc3f0dcfe 100644 --- a/tests/unit/openpype/conftest.py +++ b/tests/unit/openpype/conftest.py @@ -27,7 +27,6 @@ import os if not os.environ.get("IS_TEST"): # running tests from cmd or CI - os.environ["AVALON_MONGO"] = "mongodb://localhost:27017" os.environ["OPENPYPE_MONGO"] = "mongodb://localhost:27017" os.environ["AVALON_DB"] = "avalon" os.environ["OPENPYPE_DATABASE_NAME"] = "avalon" From 0a642d475cda961e033f2b4aa58e5dd09e7ec781 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 29 Mar 2023 13:19:02 +0200 Subject: [PATCH 12/15] OP-3951 - changed debug value Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- tests/unit/openpype/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/openpype/conftest.py b/tests/unit/openpype/conftest.py index 0bc3f0dcfe..9b5be54a0d 100644 --- a/tests/unit/openpype/conftest.py +++ b/tests/unit/openpype/conftest.py @@ -31,6 +31,6 @@ if not os.environ.get("IS_TEST"): # running tests from cmd or CI os.environ["AVALON_DB"] = "avalon" os.environ["OPENPYPE_DATABASE_NAME"] = "avalon" os.environ["AVALON_TIMEOUT"] = '3000' - os.environ["OPENPYPE_DEBUG"] = "3" + os.environ["OPENPYPE_DEBUG"] = "1" os.environ["AVALON_ASSET"] = "test_asset" os.environ["AVALON_PROJECT"] = "test_project" From 53d395e7087c2b4bd65c33706be25b3fb2dafb4d Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 29 Mar 2023 13:19:21 +0200 Subject: [PATCH 13/15] OP-3951 - updated value Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- tests/unit/openpype/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/openpype/conftest.py b/tests/unit/openpype/conftest.py index 9b5be54a0d..0aec25becb 100644 --- a/tests/unit/openpype/conftest.py +++ b/tests/unit/openpype/conftest.py @@ -29,7 +29,7 @@ import os if not os.environ.get("IS_TEST"): # running tests from cmd or CI os.environ["OPENPYPE_MONGO"] = "mongodb://localhost:27017" os.environ["AVALON_DB"] = "avalon" - os.environ["OPENPYPE_DATABASE_NAME"] = "avalon" + os.environ["OPENPYPE_DATABASE_NAME"] = "openpype" os.environ["AVALON_TIMEOUT"] = '3000' os.environ["OPENPYPE_DEBUG"] = "1" os.environ["AVALON_ASSET"] = "test_asset" From 97d5b187e81601864d70a84ec54f13baf885a509 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 30 Mar 2023 13:42:30 +0200 Subject: [PATCH 14/15] OP-3951 - updated logic Doesn't make sense to validate sequence for single frame. Updated tests accordingly. No sense in testing single frames so widely. --- .../publish/validate_sequence_frames.py | 2 +- .../publish/test_validate_sequence_frames.py | 36 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/openpype/plugins/publish/validate_sequence_frames.py b/openpype/plugins/publish/validate_sequence_frames.py index a804a6d9dd..6c14d0cbbf 100644 --- a/openpype/plugins/publish/validate_sequence_frames.py +++ b/openpype/plugins/publish/validate_sequence_frames.py @@ -31,7 +31,7 @@ class ValidateSequenceFrames(pyblish.api.InstancePlugin): for repr in representations: repr_files = repr["files"] if isinstance(repr_files, str): - repr_files = [repr_files] + continue ext = repr.get("ext") if not ext: diff --git a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py index e1facdc37b..f9d1e59096 100644 --- a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py +++ b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py @@ -37,7 +37,7 @@ class TestValidateSequenceFrames(BaseTest): class Instance(PyblishInstance): data = { "frameStart": 1001, - "frameEnd": 1001, + "frameEnd": 1002, "representations": [] } yield Instance @@ -57,17 +57,18 @@ class TestValidateSequenceFrames(BaseTest): } ] instance.data["representations"] = representations + instance.data["frameEnd"] = 1001 plugin.process(instance) @pytest.mark.parametrize("files", - ["Main_beauty.v001.1001.exr", - "Main_beauty_v001.1001.exr", - "Main_beauty.1001.1001.exr", - "Main_beauty_v001_1001.exr"]) - def test_validate_sequence_frames_single_frame_name(self, instance, - plugin, - files): + [ + ["Main_beauty.v001.1001.exr", "Main_beauty.v001.1002.exr"], + ["Main_beauty_v001.1001.exr", "Main_beauty_v001.1002.exr"], + ["Main_beauty.1001.1001.exr", "Main_beauty.1001.1002.exr"], + ["Main_beauty_v001_1001.exr", "Main_beauty_v001_1002.exr"]]) + def test_validate_sequence_frames_name(self, instance, + plugin, files): # tests for names with number inside, caused clique failure before representations = [ { @@ -80,10 +81,9 @@ class TestValidateSequenceFrames(BaseTest): plugin.process(instance) @pytest.mark.parametrize("files", - ["Main_beauty.1001.v001.exr"]) - def test_validate_sequence_frames_single_frame_wrong_name(self, instance, - plugin, - files): + [["Main_beauty.1001.v001.exr", "Main_beauty.1002.v001.exr"]]) + def test_validate_sequence_frames_wrong_name(self, instance, + plugin, files): # tests for names with number inside, caused clique failure before representations = [ { @@ -93,14 +93,14 @@ class TestValidateSequenceFrames(BaseTest): ] instance.data["representations"] = representations - with pytest.raises(ValueError) as excinfo: + with pytest.raises(AssertionError) as excinfo: plugin.process(instance) - assert ("Invalid frame range: (1, 1) - expected: (1001, 1001)" in + assert ("Must detect single collection" in str(excinfo.value)) @pytest.mark.parametrize("files", - ["Main_beauty.v001.1001.ass.gz"]) - def test_validate_sequence_frames_single_frame_possible_wrong_name( + [["Main_beauty.v001.1001.ass.gz", "Main_beauty.v001.1002.ass.gz"]]) + def test_validate_sequence_frames_possible_wrong_name( self, instance, plugin, files): # currently pattern fails on extensions with dots representations = [ @@ -116,8 +116,8 @@ class TestValidateSequenceFrames(BaseTest): str(excinfo.value)) @pytest.mark.parametrize("files", - ["Main_beauty.v001.1001.ass.gz"]) - def test_validate_sequence_frames_single_frame_correct_ext( + [["Main_beauty.v001.1001.ass.gz", "Main_beauty.v001.1002.ass.gz"]]) + def test_validate_sequence_frames__correct_ext( self, instance, plugin, files): # currently pattern fails on extensions with dots representations = [ From 80c50af2b903737c3d4635063423876cc3b9d210 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 30 Mar 2023 13:45:37 +0200 Subject: [PATCH 15/15] OP-3951 - Hound --- .../publish/test_validate_sequence_frames.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py index f9d1e59096..58d9de011d 100644 --- a/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py +++ b/tests/unit/openpype/plugins/publish/test_validate_sequence_frames.py @@ -63,10 +63,14 @@ class TestValidateSequenceFrames(BaseTest): @pytest.mark.parametrize("files", [ - ["Main_beauty.v001.1001.exr", "Main_beauty.v001.1002.exr"], - ["Main_beauty_v001.1001.exr", "Main_beauty_v001.1002.exr"], - ["Main_beauty.1001.1001.exr", "Main_beauty.1001.1002.exr"], - ["Main_beauty_v001_1001.exr", "Main_beauty_v001_1002.exr"]]) + ["Main_beauty.v001.1001.exr", + "Main_beauty.v001.1002.exr"], + ["Main_beauty_v001.1001.exr", + "Main_beauty_v001.1002.exr"], + ["Main_beauty.1001.1001.exr", + "Main_beauty.1001.1002.exr"], + ["Main_beauty_v001_1001.exr", + "Main_beauty_v001_1002.exr"]]) def test_validate_sequence_frames_name(self, instance, plugin, files): # tests for names with number inside, caused clique failure before @@ -81,7 +85,8 @@ class TestValidateSequenceFrames(BaseTest): plugin.process(instance) @pytest.mark.parametrize("files", - [["Main_beauty.1001.v001.exr", "Main_beauty.1002.v001.exr"]]) + [["Main_beauty.1001.v001.exr", + "Main_beauty.1002.v001.exr"]]) def test_validate_sequence_frames_wrong_name(self, instance, plugin, files): # tests for names with number inside, caused clique failure before @@ -99,7 +104,8 @@ class TestValidateSequenceFrames(BaseTest): str(excinfo.value)) @pytest.mark.parametrize("files", - [["Main_beauty.v001.1001.ass.gz", "Main_beauty.v001.1002.ass.gz"]]) + [["Main_beauty.v001.1001.ass.gz", + "Main_beauty.v001.1002.ass.gz"]]) def test_validate_sequence_frames_possible_wrong_name( self, instance, plugin, files): # currently pattern fails on extensions with dots @@ -116,7 +122,8 @@ class TestValidateSequenceFrames(BaseTest): str(excinfo.value)) @pytest.mark.parametrize("files", - [["Main_beauty.v001.1001.ass.gz", "Main_beauty.v001.1002.ass.gz"]]) + [["Main_beauty.v001.1001.ass.gz", + "Main_beauty.v001.1002.ass.gz"]]) def test_validate_sequence_frames__correct_ext( self, instance, plugin, files): # currently pattern fails on extensions with dots