testing: publish plugins finalisation

This commit is contained in:
Jakub Jezek 2023-01-05 17:16:42 +01:00
parent b084b7020e
commit f2a9169ffd
No known key found for this signature in database
GPG key ID: 730D7C02726179A7

View file

@ -13,11 +13,13 @@
removes temporary folder
removes temporary databases (?)
"""
import pytest
import os
import pytest
import shutil
from tests.unit.openpype.pipeline.lib import TestPipeline
from openpype.pipeline.publish import publish_plugins
from openpype.pipeline import colorspace
class TestPipelinePublishPlugins(TestPipeline):
@ -50,16 +52,79 @@ class TestPipelinePublishPlugins(TestPipeline):
}
yield CTX
def test_config_file_project(self, context):
@pytest.fixture(scope="module")
def config_path_project(
self,
download_test_data,
output_folder_url
):
src_path = os.path.join(
download_test_data,
"input",
"data",
"configs",
"aces_1.3",
"ayon_aces_config_project.ocio"
)
dest_dir = os.path.join(
output_folder_url,
self.PROJECT,
"ocio"
)
dest_path = os.path.join(
dest_dir,
"config.ocio"
)
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
shutil.copyfile(src_path, dest_path)
yield dest_path
@pytest.fixture(scope="module")
def config_path_asset(
self,
download_test_data,
output_folder_url
):
src_path = os.path.join(
download_test_data,
"input",
"data",
"configs",
"aces_1.3",
"ayon_aces_config_asset.ocio"
)
dest_dir = os.path.join(
output_folder_url,
self.PROJECT,
self.ASSET,
"ocio"
)
dest_path = os.path.join(
dest_dir,
"config.ocio"
)
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
shutil.copyfile(src_path, dest_path)
yield dest_path
def test_get_colorspace_settings(self, context):
expected_config_template = (
"{root[work]}/{project[name]}/{asset}/ocio/config.ocio")
expected_file_rules = {
"comp_review": {
"pattern": "renderCompMain.baking_h264",
"colorspace": "Output - Rec.709",
"colorspace": "Camera Rec.709",
"ext": "mp4"
}
}
# load plugin function for testing
plugin = publish_plugins.ExtractorColormanaged()
config_data, file_rules = plugin.get_colorspace_settings(context)
@ -72,5 +137,67 @@ class TestPipelinePublishPlugins(TestPipeline):
f"matching {expected_file_rules}"
)
def test_set_representation_colorspace(
self, context, project_settings,
config_path_project, config_path_asset
):
expected_colorspace_hiero = "sRGB - Texture"
expected_colorspace_nuke = "Camera Rec.709"
config_data_nuke = colorspace.get_imageio_config(
"test_project", "nuke", project_settings)
file_rules_nuke = colorspace.get_imageio_file_rules(
"test_project", "nuke", project_settings)
config_data_hiero = colorspace.get_imageio_config(
"test_project", "hiero", project_settings)
file_rules_hiero = colorspace.get_imageio_file_rules(
"test_project", "hiero", project_settings)
representation_nuke = {
"ext": "mp4",
"files": "this_file_renderCompMain.baking_h264.mp4"
}
representation_hiero = {
"ext": "mp4",
"files": "this_file_renderCompMain_h264burninburnin.mp4"
}
# load plugin function for testing
plugin = publish_plugins.ExtractorColormanaged()
plugin.set_representation_colorspace(
representation_nuke, context,
config_data_nuke, file_rules_nuke
)
# load plugin function for testing
plugin = publish_plugins.ExtractorColormanaged()
plugin.set_representation_colorspace(
representation_hiero, context,
config_data_hiero, file_rules_hiero
)
colorspace_data_nuke = representation_nuke.get("colorspaceData")
colorspace_data_hiero = representation_hiero.get("colorspaceData")
assert colorspace_data_nuke, (
"Colorspace data were not created in prepresentation"
f"matching {representation_nuke}"
)
assert colorspace_data_hiero, (
"Colorspace data were not created in prepresentation"
f"matching {representation_hiero}"
)
ret_colorspace_nuke = colorspace_data_nuke["colorspace"]
assert ret_colorspace_nuke == expected_colorspace_nuke, (
"Returned colorspace is not "
f"matching {expected_colorspace_nuke}"
)
ret_colorspace_hiero = colorspace_data_hiero["colorspace"]
assert ret_colorspace_hiero == expected_colorspace_hiero, (
"Returned colorspace is not "
f"matching {expected_colorspace_hiero}"
)
test_case = TestPipelinePublishPlugins()