mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Tests: fix unit tests (#5533)
* Changed test zip file location * Updated tests and updated Unreal plugin Unreal plugin was previously ejected into general one, which was later removed as unnecessary. In Unreal plugin were kept fixed bugs from general one (slate issue, better name pattern for clique) * Updated raised exception type
This commit is contained in:
parent
e56d3530cb
commit
04145020f6
4 changed files with 39 additions and 46 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import clique
|
||||
import os
|
||||
import re
|
||||
|
||||
import pyblish.api
|
||||
|
||||
|
|
@ -21,7 +23,19 @@ class ValidateSequenceFrames(pyblish.api.InstancePlugin):
|
|||
representations = instance.data.get("representations")
|
||||
for repr in representations:
|
||||
data = instance.data.get("assetEntity", {}).get("data", {})
|
||||
patterns = [clique.PATTERNS["frames"]]
|
||||
repr_files = repr["files"]
|
||||
if isinstance(repr_files, str):
|
||||
continue
|
||||
|
||||
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<index>(?P<padding>0*)\d+){}$".format(
|
||||
re.escape(ext))
|
||||
patterns = [pattern]
|
||||
|
||||
collections, remainder = clique.assemble(
|
||||
repr["files"], minimum_items=1, patterns=patterns)
|
||||
|
||||
|
|
@ -30,6 +44,10 @@ class ValidateSequenceFrames(pyblish.api.InstancePlugin):
|
|||
collection = collections[0]
|
||||
frames = list(collection.indexes)
|
||||
|
||||
if instance.data.get("slate"):
|
||||
# Slate is not part of the frame range
|
||||
frames = frames[1:]
|
||||
|
||||
current_range = (frames[0], frames[-1])
|
||||
required_range = (data["clipIn"],
|
||||
data["clipOut"])
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import logging
|
|||
from pyblish.api import Instance as PyblishInstance
|
||||
|
||||
from tests.lib.testing_classes import BaseTest
|
||||
from openpype.plugins.publish.validate_sequence_frames import (
|
||||
from openpype.hosts.unreal.plugins.publish.validate_sequence_frames import (
|
||||
ValidateSequenceFrames
|
||||
)
|
||||
|
||||
|
|
@ -38,7 +38,13 @@ class TestValidateSequenceFrames(BaseTest):
|
|||
data = {
|
||||
"frameStart": 1001,
|
||||
"frameEnd": 1002,
|
||||
"representations": []
|
||||
"representations": [],
|
||||
"assetEntity": {
|
||||
"data": {
|
||||
"clipIn": 1001,
|
||||
"clipOut": 1002,
|
||||
}
|
||||
}
|
||||
}
|
||||
yield Instance
|
||||
|
||||
|
|
@ -58,6 +64,7 @@ class TestValidateSequenceFrames(BaseTest):
|
|||
]
|
||||
instance.data["representations"] = representations
|
||||
instance.data["frameEnd"] = 1001
|
||||
instance.data["assetEntity"]["data"]["clipOut"] = 1001
|
||||
|
||||
plugin.process(instance)
|
||||
|
||||
|
|
@ -84,49 +91,11 @@ class TestValidateSequenceFrames(BaseTest):
|
|||
|
||||
plugin.process(instance)
|
||||
|
||||
@pytest.mark.parametrize("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 = [
|
||||
{
|
||||
"ext": "exr",
|
||||
"files": files,
|
||||
}
|
||||
]
|
||||
instance.data["representations"] = representations
|
||||
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
plugin.process(instance)
|
||||
assert ("Must detect single collection" in
|
||||
str(excinfo.value))
|
||||
|
||||
@pytest.mark.parametrize("files",
|
||||
[["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 = [
|
||||
{
|
||||
"files": files,
|
||||
}
|
||||
]
|
||||
instance.data["representations"] = representations
|
||||
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
plugin.process(instance)
|
||||
assert ("Must not have remainder" in
|
||||
str(excinfo.value))
|
||||
|
||||
@pytest.mark.parametrize("files",
|
||||
[["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 = [
|
||||
{
|
||||
"ext": "ass.gz",
|
||||
|
|
@ -147,6 +116,7 @@ class TestValidateSequenceFrames(BaseTest):
|
|||
]
|
||||
instance.data["representations"] = representations
|
||||
instance.data["frameEnd"] = 1003
|
||||
instance.data["assetEntity"]["data"]["clipOut"] = 1003
|
||||
|
||||
plugin.process(instance)
|
||||
|
||||
|
|
@ -160,6 +130,7 @@ class TestValidateSequenceFrames(BaseTest):
|
|||
]
|
||||
instance.data["representations"] = representations
|
||||
instance.data["frameEnd"] = 1003
|
||||
instance.data["assetEntity"]["data"]["clipOut"] = 1003
|
||||
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
plugin.process(instance)
|
||||
|
|
@ -175,6 +146,7 @@ class TestValidateSequenceFrames(BaseTest):
|
|||
]
|
||||
instance.data["representations"] = representations
|
||||
instance.data["frameEnd"] = 1003
|
||||
instance.data["assetEntity"]["data"]["clipOut"] = 1003
|
||||
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
plugin.process(instance)
|
||||
|
|
@ -195,6 +167,7 @@ class TestValidateSequenceFrames(BaseTest):
|
|||
instance.data["slate"] = True
|
||||
instance.data["representations"] = representations
|
||||
instance.data["frameEnd"] = 1003
|
||||
instance.data["assetEntity"]["data"]["clipOut"] = 1003
|
||||
|
||||
plugin.process(instance)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Test suite for delivery functions."""
|
||||
from openpype.lib.delivery import collect_frames
|
||||
from openpype.lib import collect_frames
|
||||
|
||||
|
||||
def test_collect_frames_multi_sequence():
|
||||
|
|
@ -153,4 +153,3 @@ def test_collect_frames_single_file():
|
|||
|
||||
print(ret)
|
||||
assert ret == expected, "Not matching"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,16 +12,19 @@
|
|||
removes temporary databases (?)
|
||||
"""
|
||||
import pytest
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
from tests.lib.testing_classes import ModuleUnitTest
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
from openpype.modules.sync_server.utils import SiteAlreadyPresentError
|
||||
|
||||
|
||||
|
||||
class TestSiteOperation(ModuleUnitTest):
|
||||
|
||||
REPRESENTATION_ID = "60e578d0c987036c6a7b741d"
|
||||
|
||||
TEST_FILES = [("1eCwPljuJeOI8A3aisfOIBKKjcmIycTEt",
|
||||
TEST_FILES = [("1FHE70Hi7y05LLT_1O3Y6jGxwZGXKV9zX",
|
||||
"test_site_operations.zip", '')]
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
|
@ -71,7 +74,7 @@ class TestSiteOperation(ModuleUnitTest):
|
|||
@pytest.mark.usefixtures("setup_sync_server_module")
|
||||
def test_add_site_again(self, dbcon, setup_sync_server_module):
|
||||
"""Depends on test_add_site, must throw exception."""
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(SiteAlreadyPresentError):
|
||||
setup_sync_server_module.add_site(self.TEST_PROJECT_NAME,
|
||||
self.REPRESENTATION_ID,
|
||||
site_name='test_site')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue