|
|
|
@ -1,4 +1,3 @@
|
|
|
|
import cv2
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
import numpy as np
|
|
|
|
import os.path as osp
|
|
|
|
import os.path as osp
|
|
|
|
|
|
|
|
|
|
|
|
@ -7,15 +6,15 @@ from unittest import TestCase
|
|
|
|
from datumaro.components.project import Project
|
|
|
|
from datumaro.components.project import Project
|
|
|
|
from datumaro.util.command_targets import ProjectTarget, \
|
|
|
|
from datumaro.util.command_targets import ProjectTarget, \
|
|
|
|
ImageTarget, SourceTarget
|
|
|
|
ImageTarget, SourceTarget
|
|
|
|
from datumaro.util.test_utils import current_function_name, TestDir
|
|
|
|
from datumaro.util.image import save_image
|
|
|
|
|
|
|
|
from datumaro.util.test_utils import TestDir
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CommandTargetsTest(TestCase):
|
|
|
|
class CommandTargetsTest(TestCase):
|
|
|
|
def test_image_false_when_no_file(self):
|
|
|
|
def test_image_false_when_no_file(self):
|
|
|
|
path = '%s.jpg' % current_function_name()
|
|
|
|
|
|
|
|
target = ImageTarget()
|
|
|
|
target = ImageTarget()
|
|
|
|
|
|
|
|
|
|
|
|
status = target.test(path)
|
|
|
|
status = target.test('somepath.jpg')
|
|
|
|
|
|
|
|
|
|
|
|
self.assertFalse(status)
|
|
|
|
self.assertFalse(status)
|
|
|
|
|
|
|
|
|
|
|
|
@ -34,8 +33,7 @@ class CommandTargetsTest(TestCase):
|
|
|
|
def test_image_true_when_true(self):
|
|
|
|
def test_image_true_when_true(self):
|
|
|
|
with TestDir() as test_dir:
|
|
|
|
with TestDir() as test_dir:
|
|
|
|
path = osp.join(test_dir, 'test.jpg')
|
|
|
|
path = osp.join(test_dir, 'test.jpg')
|
|
|
|
image = np.random.random_sample([10, 10, 3])
|
|
|
|
save_image(path, np.ones([10, 7, 3]))
|
|
|
|
cv2.imwrite(path, image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
target = ImageTarget()
|
|
|
|
target = ImageTarget()
|
|
|
|
|
|
|
|
|
|
|
|
@ -44,10 +42,9 @@ class CommandTargetsTest(TestCase):
|
|
|
|
self.assertTrue(status)
|
|
|
|
self.assertTrue(status)
|
|
|
|
|
|
|
|
|
|
|
|
def test_project_false_when_no_file(self):
|
|
|
|
def test_project_false_when_no_file(self):
|
|
|
|
path = '%s.jpg' % current_function_name()
|
|
|
|
|
|
|
|
target = ProjectTarget()
|
|
|
|
target = ProjectTarget()
|
|
|
|
|
|
|
|
|
|
|
|
status = target.test(path)
|
|
|
|
status = target.test('somepath.jpg')
|
|
|
|
|
|
|
|
|
|
|
|
self.assertFalse(status)
|
|
|
|
self.assertFalse(status)
|
|
|
|
|
|
|
|
|
|
|
|
|