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:
Petr Kalis 2023-08-29 17:35:48 +02:00 committed by GitHub
parent e56d3530cb
commit 04145020f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 46 deletions

View file

@ -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)

View file

@ -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"

View file

@ -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')