def test_get_model_from_exif(self): testdata.create_test_data() self.log_testcase_name(inspect.currentframe().f_code.co_name) with open(os.path.join("source", "IMG_4810.jpeg"), 'rb') as exif_file: image_file = Image.open(exif_file) exif_data = image_file._getexif() self.assertEqual(get_model_from_exif(exif_data), "iPhone X") testdata.cleanup_test_data()
def test_no_model_in_exif(self): self.log_testcase_name(inspect.currentframe().f_code.co_name) testdata.create_test_data() mediasort.scan_files("source", "target", 0, output_formats['MONTHLY']) self.assertTrue( os.path.exists(os.path.join("target", "2020-05", "other"))) self.assertTrue( os.path.isfile( os.path.join("target", "2020-05", "other", "IMG_20200506-125846.jpg"))) testdata.cleanup_test_data()
def test_other_output(self): self.log_testcase_name(inspect.currentframe().f_code.co_name) testdata.create_test_data() mediasort.scan_files("source", "target", 0, output_formats['MONTHLY']) self.assertTrue( os.path.exists(os.path.join("target", "2019-06", "other"))) self.assertTrue( os.path.isfile( os.path.join("target", "2019-06", "other", "IMG_20190610_190809.JPG"))) testdata.cleanup_test_data()
def test_recursion_lvl2(self): self.log_testcase_name(inspect.currentframe().f_code.co_name) testdata.create_test_data() mediasort.scan_files("source", "target", 2, output_formats['YEARLY']) self.assertTrue(os.path.exists(os.path.join("target", "1975"))) self.assertTrue( os.path.isfile( os.path.join("target", "1975", "video", "file11-19750517_091500.mp4"))) self.assertTrue( os.path.isfile( os.path.join("target", "1975", "video", "file21-19750517_091500.mp4"))) testdata.cleanup_test_data()
def test_monthly_output(self): self.log_testcase_name(inspect.currentframe().f_code.co_name) testdata.create_test_data() mediasort.scan_files("source", "target", 0, output_formats['MONTHLY']) self.assertTrue(os.path.exists("source")) self.assertTrue(os.path.exists(os.path.join("target", "2019-08"))) self.assertTrue( os.path.exists(os.path.join("target", "1975-05", "video"))) self.assertTrue( os.path.isfile( os.path.join("target", "1975-05", "video", "file-19750517_091500.mp4"))) self.assertTrue( os.path.isfile(os.path.join("target", "2019-08", "IMG_4810.jpeg"))) testdata.cleanup_test_data()
def test_yearly_output(self): self.log_testcase_name(inspect.currentframe().f_code.co_name) testdata.create_test_data() mediasort.scan_files("source", "target", 0, output_formats['YEARLY']) self.assertTrue(os.path.exists(os.path.join("target", "2019"))) self.assertTrue(os.path.exists(os.path.join("target", "1975"))) self.assertTrue( os.path.isfile(os.path.join("target", "2019", "IMG_4810.jpeg"))) self.assertTrue( os.path.isfile( os.path.join("target", "2019", "other", "IMG_20190610_190809.JPG"))) self.assertTrue( os.path.isfile( os.path.join("target", "1975", "video", "file-19750517-0915_bla.mp4"))) testdata.cleanup_test_data()
def test_detect_already_sorted(self): self.log_testcase_name(inspect.currentframe().f_code.co_name) testdata.create_test_data() mediasort.scan_files("source", "source", 1, output_formats['MONTHLY']) self.assertTrue( os.path.exists(os.path.join("source", "1975-05", "video"))) self.assertTrue( os.path.isfile( os.path.join("source", "1975-05", "video", "file-19750517_091500.mp4"))) self.assertTrue(os.path.exists(os.path.join("source", "2019-08"))) self.assertTrue( os.path.isfile(os.path.join("source", "2019-08", "IMG_4810.jpeg"))) mediasort.scan_files("source", "source", 2, output_formats['MONTHLY']) self.assertFalse(os.path.exists(os.path.join("source", "2019", "2019"))) self.assertFalse(os.path.exists(os.path.join("source", "2020", "2020"))) testdata.cleanup_test_data()
def test_daily_output(self): self.log_testcase_name(inspect.currentframe().f_code.co_name) testdata.create_test_data() mediasort.scan_files("source", "target", 0, output_formats['DAILY']) self.assertTrue( os.path.exists(os.path.join("target", "1975-05-17-Sat"))) self.assertTrue( os.path.isfile( os.path.join("target", "1975-05-17-Sat", "video", "file-19750517_091500.mp4"))) self.assertTrue( os.path.isfile( os.path.join("target", "1975-05-17-Sat", "video", "file-19750517_091500_1.mp4"))) self.assertTrue( os.path.isfile( os.path.join("target", "1975-05-17-Sat", "video", "file-19750517-091500.mp4"))) testdata.cleanup_test_data()
self.assertEqual(self.retriever.get_interval_sequence(interval), "CTT") def test_reversed_single_node_interval_with_dual_offsetl(self): interval = Interval(1, 2, [-3]) self.assertEqual(self.retriever.get_interval_sequence(interval), "C") def test_multiple_nodes_interval(self): interval = Interval(0, 3, [1, 2]) self.assertEqual(self.retriever.get_interval_sequence(interval), "AAGGAA") def test_multiple_nodes_interval_second_rp_reversed(self): interval = Interval(0, 3, [1, -2]) self.assertEqual(self.retriever.get_interval_sequence(interval), "AAGTTC") def test_long_interval(self): interval = Interval(1, 1, [1, 2, 3, -3, -2, -1]) self.assertEqual(self.retriever.get_interval_sequence(interval), "AGGAAAGATCTTTCC") def test_from_vg_json_graph(self): retriever = SequenceRetriever.from_vg_json_graph( "tests/simple_graph.json") self.assertEqual(retriever.get_sequence(1, 0, 7), "tttcccc") if __name__ == "__main__": create_test_data() unittest.main()