class FrameLoaderTest(unittest.TestCase): def create_dummy_frames(self, num_frames=NUM_FRAMES, filters=[]): if not filters: filters = range(num_frames) for i in filters: yield Frame( i, np.array(np.ones((2, 2, 3)) * 0.1 * float(i + 1) * 255, dtype=np.uint8), FrameInfo(2, 2, 3, ColorSpace.BGR)) def setUp(self): suppress_py4j_logging() self.create_dummy_frames(NUM_FRAMES) def tearDown(self): self.session = Session() self.session.stop() def test_frameinfo_information(self): frame_info = FrameInfo(2, 2, 3, ColorSpace.BGR) f = FrameLoader("appname", frame_info) self.assertEqual(f.H, 2) def test_load_images(self): frame_info = FrameInfo(28, 28, 1, ColorSpace.GRAY) f = FrameLoader("mnist", frame_info) f.load_images()
class CatalogManagerTests(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def setUp(self): suppress_py4j_logging() def tearDown(self): self.session = Session() self.session.stop() @mock.patch('src.catalog.catalog_manager.init_db') def test_catalog_manager_singleton_pattern(self, mocked_db): x = CatalogManager() y = CatalogManager() self.assertEqual(x, y)
class SparkSessionTest(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def setUp(self): self.session = Session() def tearDown(self): self.session = Session() self.session.stop() def test_session(self): spark_session = self.session.get_session() session2 = Session() self.assertEqual(self.session, session2) self.assertIsInstance(spark_session, SparkSession)