Commit 08f044d4 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

add test case with data on server

parent 99cd6137
Pipeline #1466 failed with stage
in 0 seconds
import os
import unittest import unittest
import numpy as np import numpy as np
...@@ -17,10 +18,30 @@ class FlipImageTestCase(unittest.TestCase): ...@@ -17,10 +18,30 @@ class FlipImageTestCase(unittest.TestCase):
with self.assertRaises(AssertionError): with self.assertRaises(AssertionError):
flip_image(np.array([1, 2, 3, 4])) flip_image(np.array([1, 2, 3, 4]))
def test_flip_image_on_server(self):
"""test flip image on server"""
image_input = np.load(
os.path.join(
os.environ["UNIT_TEST_DATA_ROOT"],
"csst_proto/test_flip/input/image.txt",
)
)
image_answer = np.load(
os.path.join(
os.environ["UNIT_TEST_DATA_ROOT"],
"csst_proto/test_flip/answer/flipped_image.txt",
)
)
self.assertIs(
flip_image(image_input),
image_answer,
"Test flip image on server failed",
)
def test_flip_multiple_images_mp(self): def test_flip_multiple_images_mp(self):
"""test flip multiple images with multiprocessing""" """test flip multiple images with multiprocessing"""
n_jobs = 10 n_jobs = 10
imgs = [read_default_image() for i_job in range(n_jobs)] imgs = [read_default_image() for _ in range(n_jobs)]
flipped_imgs = flip_multiple_images_mp(imgs, n_jobs) flipped_imgs = flip_multiple_images_mp(imgs, n_jobs)
for i_job in range(n_jobs): for i_job in range(n_jobs):
self.assertTrue(np.all(flipped_imgs[i_job] == np.array([[4, 3], [2, 1]]))) self.assertTrue(np.all(flipped_imgs[i_job] == np.array([[4, 3], [2, 1]])))
...@@ -28,7 +49,7 @@ class FlipImageTestCase(unittest.TestCase): ...@@ -28,7 +49,7 @@ class FlipImageTestCase(unittest.TestCase):
def test_flip_multiple_images_jl(self): def test_flip_multiple_images_jl(self):
"""test flip multiple images with joblib""" """test flip multiple images with joblib"""
n_jobs = 10 n_jobs = 10
imgs = [read_default_image() for i_job in range(n_jobs)] imgs = [read_default_image() for _ in range(n_jobs)]
flipped_imgs = flip_multiple_images_jl(imgs, n_jobs) flipped_imgs = flip_multiple_images_jl(imgs, n_jobs)
for i_job in range(n_jobs): for i_job in range(n_jobs):
self.assertTrue(np.all(flipped_imgs[i_job] == np.array([[4, 3], [2, 1]]))) self.assertTrue(np.all(flipped_imgs[i_job] == np.array([[4, 3], [2, 1]])))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment