Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Added matcher unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kmazurek committed May 13, 2019
1 parent ea1feeb commit 78ddd7a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import typing

from . import types

TYPES = [
FILE_TYPES = [
types.Bmp(),
types.Jpeg(),
types.Tga()
Expand All @@ -22,9 +20,8 @@ def get_expected_extension(extension: str) -> str:
"""
lower_extension = extension.lower()

for file_type in TYPES:
for file_type in FILE_TYPES:
if lower_extension in file_type.extensions:
return file_type.output_format

return lower_extension

Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ def extensions(self) -> typing.AbstractSet[str]:
@property
def output_format(self) -> str:
return '.tga'

Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def prepare_params(mounted_paths, subtask_border, scene_file_path, resolution, s

def make_verdict( subtask_file_paths, crops, results ):
verdict = True
print(f'make_verdict, crops: {crops}')
print(f'make_verdict, results: {results}')

for crop_data in results:
crop = get_crop_with_id(crop_data['crop']['id'], crops)
Expand Down
31 changes: 31 additions & 0 deletions tests/apps/blender/verification/test_extension_matcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import typing
import unittest

from apps.blender.resources.images.entrypoints.\
scripts.verifier_tools.file_extension import matcher, types


class TestExtensionMatcher(unittest.TestCase):
def test_bmp_expected_extension(self):
self._assert_expected_extension(types.Bmp().extensions, '.bmp')

def test_jpeg_expected_extension(self):
self._assert_expected_extension(types.Jpeg().extensions, '.jpg')

def test_tga_expected_extension(self):
self._assert_expected_extension(types.Tga().extensions, '.tga')

def test_unknown_extension(self):
extension = '.unkwn'

alias = matcher.get_expected_extension(extension)

self.assertEqual(extension, alias)

def _assert_expected_extension(
self,
aliases: typing.Iterable[str],
expected: str
):
for alias in aliases:
self.assertEqual(matcher.get_expected_extension(alias), expected)

0 comments on commit 78ddd7a

Please # to comment.