From a312ac7ff2b88fed6e81baa92d669f532dcd99fe Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Thu, 12 Dec 2024 17:41:04 +0100 Subject: [PATCH] :alembic: fix the test stub for `get_transfers_from_representation` --- .../plugins/publish/integrate_traits.py | 5 +-- .../plugins/publish/test_integrate_traits.py | 35 +++++-------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/client/ayon_core/plugins/publish/integrate_traits.py b/client/ayon_core/plugins/publish/integrate_traits.py index a816a42c3f..43f979b196 100644 --- a/client/ayon_core/plugins/publish/integrate_traits.py +++ b/client/ayon_core/plugins/publish/integrate_traits.py @@ -826,7 +826,8 @@ class IntegrateTraits(pyblish.api.InstancePlugin): ) ) - # add template path and the data to resolve it + # add template path and the data to resolve it + if not representation.contains_trait(TemplatePath): representation.add_trait(TemplatePath( template=template_item.template, data=template_item.template_data @@ -908,7 +909,7 @@ class IntegrateTraits(pyblish.api.InstancePlugin): template_item.template_object["path"] ) template_item.template_data["ext"] = ( - representation.get_trait(FileLocation).file_path.suffix + representation.get_trait(FileLocation).file_path.suffix.rstrip(".") ) template_item.template_data.pop("frame", None) with contextlib.suppress(MissingTraitError): diff --git a/tests/client/ayon_core/plugins/publish/test_integrate_traits.py b/tests/client/ayon_core/plugins/publish/test_integrate_traits.py index 41f952f962..95c0eb52a8 100644 --- a/tests/client/ayon_core/plugins/publish/test_integrate_traits.py +++ b/tests/client/ayon_core/plugins/publish/test_integrate_traits.py @@ -163,7 +163,7 @@ def mock_context( ), Sequence( frame_padding=4, - frame_regex=r"^img\.(?P\d{4})\.png$", + frame_regex=r"img\.(?P(?P0*)\d{4})\.png$", ), FileLocations( file_paths=file_locations, @@ -269,7 +269,13 @@ def test_prepare_version( def test_get_transfers_from_representation( mock_context: pyblish.api.Context) -> None: - """Test get_transfers_from_representation.""" + """Test get_transfers_from_representation. + + Todo: This test will benefit massively from a proper mocking of the + context. We need to parametrize the test with different + representations and test the output of the function. + + """ integrator = IntegrateTraits() instance = mock_context[0] @@ -278,27 +284,4 @@ def test_get_transfers_from_representation( transfers = integrator.get_transfers_from_representations( instance, representations) - assert transfers == [ - { - "file_path": Path("test"), - "file_size": 1234, - "traits": [ - "Persistent", - "Image", - "MimeType" - ] - }, - { - "file_path": Path("test"), - "file_size": 1234, - "traits": [ - "Persistent", - "FrameRanged", - "Sequence", - "FileLocations", - "Image", - "PixelBased", - "MimeType" - ] - } - ] + assert len(transfers) == 11