mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge remote-tracking branch 'origin/develop' into feature/909-define-basic-trait-type-using-dataclasses
This commit is contained in:
commit
a5228b057d
38 changed files with 4294 additions and 885 deletions
135
tests/client/ayon_core/lib/test_env_tools.py
Normal file
135
tests/client/ayon_core/lib/test_env_tools.py
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from ayon_core.lib.env_tools import (
|
||||
CycleError,
|
||||
DynamicKeyClashError,
|
||||
parse_env_variables_structure,
|
||||
compute_env_variables_structure,
|
||||
)
|
||||
|
||||
# --- Test data ---
|
||||
COMPUTE_SRC_ENV = {
|
||||
"COMPUTE_VERSION": "1.0.0",
|
||||
# Will be available only for darwin
|
||||
"COMPUTE_ONE_PLATFORM": {
|
||||
"darwin": "Compute macOs",
|
||||
},
|
||||
"COMPUTE_LOCATION": {
|
||||
"darwin": "/compute-app-{COMPUTE_VERSION}",
|
||||
"linux": "/usr/compute-app-{COMPUTE_VERSION}",
|
||||
"windows": "C:/Program Files/compute-app-{COMPUTE_VERSION}"
|
||||
},
|
||||
"PATH_LIST": {
|
||||
"darwin": ["{COMPUTE_LOCATION}/bin", "{COMPUTE_LOCATION}/bin2"],
|
||||
"linux": ["{COMPUTE_LOCATION}/bin", "{COMPUTE_LOCATION}/bin2"],
|
||||
"windows": ["{COMPUTE_LOCATION}/bin", "{COMPUTE_LOCATION}/bin2"],
|
||||
},
|
||||
"PATH_STR": {
|
||||
"darwin": "{COMPUTE_LOCATION}/bin:{COMPUTE_LOCATION}/bin2",
|
||||
"linux": "{COMPUTE_LOCATION}/bin:{COMPUTE_LOCATION}/bin2",
|
||||
"windows": "{COMPUTE_LOCATION}/bin;{COMPUTE_LOCATION}/bin2",
|
||||
},
|
||||
}
|
||||
|
||||
# --- RESULTS ---
|
||||
# --- Parse results ---
|
||||
PARSE_RESULT_WINDOWS = {
|
||||
"COMPUTE_VERSION": "1.0.0",
|
||||
"COMPUTE_LOCATION": "C:/Program Files/compute-app-{COMPUTE_VERSION}",
|
||||
"PATH_LIST": "{COMPUTE_LOCATION}/bin;{COMPUTE_LOCATION}/bin2",
|
||||
"PATH_STR": "{COMPUTE_LOCATION}/bin;{COMPUTE_LOCATION}/bin2",
|
||||
}
|
||||
|
||||
PARSE_RESULT_LINUX = {
|
||||
"COMPUTE_VERSION": "1.0.0",
|
||||
"COMPUTE_LOCATION": "/usr/compute-app-{COMPUTE_VERSION}",
|
||||
"PATH_LIST": "{COMPUTE_LOCATION}/bin:{COMPUTE_LOCATION}/bin2",
|
||||
"PATH_STR": "{COMPUTE_LOCATION}/bin:{COMPUTE_LOCATION}/bin2",
|
||||
}
|
||||
|
||||
PARSE_RESULT_DARWIN = {
|
||||
"COMPUTE_VERSION": "1.0.0",
|
||||
"COMPUTE_ONE_PLATFORM": "Compute macOs",
|
||||
"COMPUTE_LOCATION": "/compute-app-{COMPUTE_VERSION}",
|
||||
"PATH_LIST": "{COMPUTE_LOCATION}/bin:{COMPUTE_LOCATION}/bin2",
|
||||
"PATH_STR": "{COMPUTE_LOCATION}/bin:{COMPUTE_LOCATION}/bin2",
|
||||
}
|
||||
|
||||
# --- Compute results ---
|
||||
COMPUTE_RESULT_WINDOWS = {
|
||||
"COMPUTE_VERSION": "1.0.0",
|
||||
"COMPUTE_LOCATION": "C:/Program Files/compute-app-1.0.0",
|
||||
"PATH_LIST": (
|
||||
"C:/Program Files/compute-app-1.0.0/bin"
|
||||
";C:/Program Files/compute-app-1.0.0/bin2"
|
||||
),
|
||||
"PATH_STR": (
|
||||
"C:/Program Files/compute-app-1.0.0/bin"
|
||||
";C:/Program Files/compute-app-1.0.0/bin2"
|
||||
)
|
||||
}
|
||||
|
||||
COMPUTE_RESULT_LINUX = {
|
||||
"COMPUTE_VERSION": "1.0.0",
|
||||
"COMPUTE_LOCATION": "/usr/compute-app-1.0.0",
|
||||
"PATH_LIST": "/usr/compute-app-1.0.0/bin:/usr/compute-app-1.0.0/bin2",
|
||||
"PATH_STR": "/usr/compute-app-1.0.0/bin:/usr/compute-app-1.0.0/bin2"
|
||||
}
|
||||
|
||||
COMPUTE_RESULT_DARWIN = {
|
||||
"COMPUTE_VERSION": "1.0.0",
|
||||
"COMPUTE_ONE_PLATFORM": "Compute macOs",
|
||||
"COMPUTE_LOCATION": "/compute-app-1.0.0",
|
||||
"PATH_LIST": "/compute-app-1.0.0/bin:/compute-app-1.0.0/bin2",
|
||||
"PATH_STR": "/compute-app-1.0.0/bin:/compute-app-1.0.0/bin2"
|
||||
}
|
||||
|
||||
|
||||
class EnvParseCompute(unittest.TestCase):
|
||||
def test_parse_env(self):
|
||||
with patch("platform.system", return_value="windows"):
|
||||
result = parse_env_variables_structure(COMPUTE_SRC_ENV)
|
||||
assert result == PARSE_RESULT_WINDOWS
|
||||
|
||||
with patch("platform.system", return_value="linux"):
|
||||
result = parse_env_variables_structure(COMPUTE_SRC_ENV)
|
||||
assert result == PARSE_RESULT_LINUX
|
||||
|
||||
with patch("platform.system", return_value="darwin"):
|
||||
result = parse_env_variables_structure(COMPUTE_SRC_ENV)
|
||||
assert result == PARSE_RESULT_DARWIN
|
||||
|
||||
def test_compute_env(self):
|
||||
with patch("platform.system", return_value="windows"):
|
||||
result = compute_env_variables_structure(
|
||||
parse_env_variables_structure(COMPUTE_SRC_ENV)
|
||||
)
|
||||
assert result == COMPUTE_RESULT_WINDOWS
|
||||
|
||||
with patch("platform.system", return_value="linux"):
|
||||
result = compute_env_variables_structure(
|
||||
parse_env_variables_structure(COMPUTE_SRC_ENV)
|
||||
)
|
||||
assert result == COMPUTE_RESULT_LINUX
|
||||
|
||||
with patch("platform.system", return_value="darwin"):
|
||||
result = compute_env_variables_structure(
|
||||
parse_env_variables_structure(COMPUTE_SRC_ENV)
|
||||
)
|
||||
assert result == COMPUTE_RESULT_DARWIN
|
||||
|
||||
def test_cycle_error(self):
|
||||
with self.assertRaises(CycleError):
|
||||
compute_env_variables_structure({
|
||||
"KEY_1": "{KEY_2}",
|
||||
"KEY_2": "{KEY_1}",
|
||||
})
|
||||
|
||||
def test_dynamic_key_error(self):
|
||||
with self.assertRaises(DynamicKeyClashError):
|
||||
compute_env_variables_structure({
|
||||
"KEY_A": "Occupied",
|
||||
"SUBKEY": "A",
|
||||
"KEY_{SUBKEY}": "Resolves as occupied key",
|
||||
})
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,128 @@
|
|||
import os
|
||||
|
||||
import opentimelineio as otio
|
||||
|
||||
from ayon_core.plugins.publish import collect_otio_frame_ranges
|
||||
|
||||
|
||||
_RESOURCE_DIR = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"resources",
|
||||
"timeline"
|
||||
)
|
||||
|
||||
|
||||
class MockInstance():
|
||||
""" Mock pyblish instance for testing purpose.
|
||||
"""
|
||||
def __init__(self, data: dict):
|
||||
self.data = data
|
||||
self.context = self
|
||||
|
||||
|
||||
def _check_expected_frame_range_values(
|
||||
clip_name: str,
|
||||
expected_data: dict,
|
||||
handle_start: int = 10,
|
||||
handle_end: int = 10,
|
||||
retimed: bool = False,
|
||||
):
|
||||
file_path = os.path.join(_RESOURCE_DIR, "timeline.json")
|
||||
otio_timeline = otio.schema.Timeline.from_json_file(file_path)
|
||||
|
||||
for otio_clip in otio_timeline.find_clips():
|
||||
if otio_clip.name == clip_name:
|
||||
break
|
||||
|
||||
instance_data = {
|
||||
"otioClip": otio_clip,
|
||||
"handleStart": handle_start,
|
||||
"handleEnd": handle_end,
|
||||
"workfileFrameStart": 1001,
|
||||
}
|
||||
if retimed:
|
||||
instance_data["shotDurationFromSource"] = True
|
||||
|
||||
instance = MockInstance(instance_data)
|
||||
|
||||
processor = collect_otio_frame_ranges.CollectOtioRanges()
|
||||
processor.process(instance)
|
||||
|
||||
# Assert expected data is subset of edited instance.
|
||||
assert expected_data.items() <= instance.data.items()
|
||||
|
||||
|
||||
def test_movie_with_timecode():
|
||||
"""
|
||||
Movie clip (with embedded timecode)
|
||||
available_range = 86531-86590 23.976fps
|
||||
source_range = 86535-86586 23.976fps
|
||||
"""
|
||||
expected_data = {
|
||||
'frameStart': 1001,
|
||||
'frameEnd': 1052,
|
||||
'clipIn': 24,
|
||||
'clipOut': 75,
|
||||
'clipInH': 14,
|
||||
'clipOutH': 85,
|
||||
'sourceStart': 86535,
|
||||
'sourceStartH': 86525,
|
||||
'sourceEnd': 86586,
|
||||
'sourceEndH': 86596,
|
||||
}
|
||||
|
||||
_check_expected_frame_range_values(
|
||||
"sh010",
|
||||
expected_data,
|
||||
)
|
||||
|
||||
|
||||
def test_image_sequence():
|
||||
"""
|
||||
EXR image sequence.
|
||||
available_range = 87399-87482 24fps
|
||||
source_range = 87311-87336 23.976fps
|
||||
"""
|
||||
expected_data = {
|
||||
'frameStart': 1001,
|
||||
'frameEnd': 1026,
|
||||
'clipIn': 76,
|
||||
'clipOut': 101,
|
||||
'clipInH': 66,
|
||||
'clipOutH': 111,
|
||||
'sourceStart': 87399,
|
||||
'sourceStartH': 87389,
|
||||
'sourceEnd': 87424,
|
||||
'sourceEndH': 87434,
|
||||
}
|
||||
|
||||
_check_expected_frame_range_values(
|
||||
"img_sequence_exr",
|
||||
expected_data,
|
||||
)
|
||||
|
||||
def test_media_retimed():
|
||||
"""
|
||||
EXR image sequence.
|
||||
available_range = 345619-345691 23.976fps
|
||||
source_range = 345623-345687 23.976fps
|
||||
TimeWarp = frozen frame.
|
||||
"""
|
||||
expected_data = {
|
||||
'frameStart': 1001,
|
||||
'frameEnd': 1065,
|
||||
'clipIn': 127,
|
||||
'clipOut': 191,
|
||||
'clipInH': 117,
|
||||
'clipOutH': 201,
|
||||
'sourceStart': 1001,
|
||||
'sourceStartH': 1001,
|
||||
'sourceEnd': 1065,
|
||||
'sourceEndH': 1065,
|
||||
}
|
||||
|
||||
_check_expected_frame_range_values(
|
||||
"P01default_twsh010",
|
||||
expected_data,
|
||||
retimed=True,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue