mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
🎨 add helpers for getting files
This commit is contained in:
parent
f4169769ac
commit
595a3546f3
3 changed files with 98 additions and 3 deletions
|
|
@ -139,3 +139,43 @@ def test_file_locations_validation() -> None:
|
|||
|
||||
with pytest.raises(TraitValidationError):
|
||||
representation.validate()
|
||||
|
||||
def test_get_file_from_frame() -> None:
|
||||
"""Test get_file_from_frame method."""
|
||||
file_locations_list = [
|
||||
FileLocation(
|
||||
file_path=Path(f"/path/to/file.{frame}.exr"),
|
||||
file_size=1024,
|
||||
file_hash=None,
|
||||
)
|
||||
for frame in range(1001, 1051)
|
||||
]
|
||||
|
||||
file_locations_trait: FileLocations = FileLocations(
|
||||
file_paths=file_locations_list)
|
||||
|
||||
assert file_locations_trait.get_file_for_frame(frame=1001) == \
|
||||
file_locations_list[0].file_path
|
||||
assert file_locations_trait.get_file_for_frame(frame=1050) == \
|
||||
file_locations_list[-1].file_path
|
||||
assert file_locations_trait.get_file_for_frame(frame=1100) is None
|
||||
|
||||
# test with custom regex
|
||||
sequence = Sequence(
|
||||
frame_padding=4,
|
||||
frame_regex=r"boo_(?P<frame>\d+)\.exr")
|
||||
file_locations_list = [
|
||||
FileLocation(
|
||||
file_path=Path(f"/path/to/boo_{frame}.exr"),
|
||||
file_size=1024,
|
||||
file_hash=None,
|
||||
)
|
||||
for frame in range(1001, 1051)
|
||||
]
|
||||
|
||||
file_locations_trait: FileLocations = FileLocations(
|
||||
file_paths=file_locations_list)
|
||||
|
||||
assert file_locations_trait.get_file_for_frame(
|
||||
frame=1001, sequence_trait=sequence) == \
|
||||
file_locations_list[0].file_path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue