예제 #1
0
    def test_rename_datadir(self):
        """test renaming with --datadir (real files in tmp env)"""

        dirs = [
            "2009-06-04",
            "2017-11-23",
        ]

        if VERBOSE:
            exipicrename.set_verbose(True)
        else:
            exipicrename.set_silent(True)

        exipicrename.set_short_names(True)
        exipicrename.set_use_ooc(False)
        exipicrename.set_dry_run(False)
        exipicrename.set_use_date_dir(True)
        exipicrename.set_use_duplicate(True)
        exipicrename.set_use_serial(True)

        with TemporaryDirectory() as temp_dir:

            fill_tmpdir(temp_dir, self.source_dir, self.testfiles)

            realfiles = [temp_dir + "/" + e for e in os.listdir(temp_dir)]

            exipicrename.exipicrename(realfiles)

            #print(os.listdir(temp_dir))

            for _dir in dirs:
                self.assertTrue(os.path.isdir(os.path.join(temp_dir, _dir)))
예제 #2
0
    def test_rename_short(self):
        """test renaming with --short (real files in tmp env)"""

        defaultfiles = [
            "20090604_184453__001.jpg", "20090604_184453__001.xml",
            "20090604_184453__001.orf", "20171123_164006__002.jpg",
            "20171123_164006__003_1.jpg", 'z_test.jpg'
        ]

        if VERBOSE:
            exipicrename.set_verbose(True)
        else:
            exipicrename.set_silent(True)

        exipicrename.set_short_names(True)
        exipicrename.set_use_ooc(False)
        exipicrename.set_dry_run(False)
        exipicrename.set_use_date_dir(False)
        exipicrename.set_use_duplicate(True)
        exipicrename.set_use_serial(True)

        with TemporaryDirectory() as temp_dir:

            fill_tmpdir(temp_dir, self.source_dir, self.testfiles)

            realfiles = [temp_dir + "/" + e for e in os.listdir(temp_dir)]

            exipicrename.exipicrename(realfiles)

            defaultfiles.sort()
            tmpdirfiles = os.listdir(temp_dir)
            tmpdirfiles.sort()
            self.assertEqual(defaultfiles, tmpdirfiles)
예제 #3
0
 def test_rename_short_names(self):
     """test option --short (virtual)"""
     exipicrename.set_dry_run(True)
     exipicrename.set_short_names(True)
     if VERBOSE:
         exipicrename.set_verbose(True)
     else:
         exipicrename.set_silent(True)
     exipicrename.set_clean_data_after_run(False)
     exipicrename.exipicrename(self.testfiles)
     index = self.TEST_FIRST_KEY
     e_dict = exipicrename.export_pic_dict()
     e_shortname = e_dict[index]['new_basename']
     self.assertEqual(e_shortname, self.TEST_SHORT_BASENAME,
                      f"wrong shortname >{e_shortname}<")
     exipicrename.clean_stored_data()
예제 #4
0
    def test_rename_with_dir(self):
        """test option --datadir (virtual)"""
        exipicrename.set_dry_run(True)
        exipicrename.set_use_date_dir(True)
        exipicrename.set_use_duplicate(True)
        exipicrename.set_use_serial(True)
        if VERBOSE:
            exipicrename.set_verbose(True)
        else:
            exipicrename.set_silent(True)
        exipicrename.set_clean_data_after_run(False)
        exipicrename.exipicrename(self.testfiles)
        e_dict = exipicrename.export_pic_dict()
        index = self.TEST_FIRST_KEY
        datestring = self.TEST_DICT_DEFAULT[index]['date']
        e_dir = e_dict[index]['new_dirname']

        self.assertTrue(
            e_dir.endswith(datestring),
            f"target path does not contain date sub-directory: >{e_dir}<")
        exipicrename.clean_stored_data()
예제 #5
0
    def test_rename_default(self):
        """test default renaming (virtual)"""
        exipicrename.set_dry_run(True)
        if VERBOSE:
            exipicrename.set_verbose(True)
        else:
            exipicrename.set_silent(True)
        exipicrename.set_short_names(False)
        exipicrename.set_use_ooc(False)
        exipicrename.set_clean_data_after_run(False)
        exipicrename.exipicrename(self.testfiles)
        e_dict = exipicrename.export_pic_dict()

        for index in self.TEST_DICT_DEFAULT:
            self.assertEqual(self.TEST_DICT_DEFAULT[index]['new_basename'],
                             e_dict[index]['new_basename'],
                             f"renaming problem\ndictionary: >{e_dict}<")
            self.assertEqual(self.TEST_DICT_DEFAULT[index]['new_extension'],
                             e_dict[index]['new_extension'],
                             f"renaming problem\ndictionary: >{e_dict}<")

        exipicrename.clean_stored_data()
예제 #6
0
 def test_rename_additional_extension(self):
     """test option --oostring (virtual)"""
     exipicrename.set_dry_run(True)
     exipicrename.set_short_names(True)
     if VERBOSE:
         exipicrename.set_verbose(True)
     else:
         exipicrename.set_silent(True)
     exipicrename.set_clean_data_after_run(False)
     exipicrename.set_use_date_dir(False)
     exipicrename.set_use_duplicate(True)
     exipicrename.set_use_serial(True)
     exipicrename.set_ooc_extension(".foobar")
     exipicrename.set_use_ooc(True)
     exipicrename.exipicrename(self.testfiles)
     index = self.TEST_FIRST_KEY
     e_dict = exipicrename.export_pic_dict()
     e_extension = e_dict[index]['new_extension']
     self.assertEqual(e_extension,
                      ".foobar" + exipicrename.get_jpg_out_extension(),
                      f"additional extension wrong >{e_extension}<")
     exipicrename.clean_stored_data()
예제 #7
0
    def test_rename_no_duplicate(self):
        """test renaming with duplicate marking number switched off (real files in tmp env)"""

        defaultfiles = [
            "20090604_184453__001__e-520__25mm__f2-8__t3200__iso100.jpg",
            "20090604_184453__001__e-520__25mm__f2-8__t3200__iso100.xml",
            "20090604_184453__001__e-520__25mm__f2-8__t3200__iso100.orf",
            "20171123_164006__002__s4mini__3mm__f2-6__t17__iso125.jpg",
            "20171123_164006__003__s4mini__3mm__f2-6__t17__iso125.jpg",
            'z_test.jpg'
        ]

        if VERBOSE:
            exipicrename.set_verbose(True)
        else:
            exipicrename.set_silent(True)

        exipicrename.set_short_names(False)
        exipicrename.set_use_ooc(False)
        exipicrename.set_dry_run(False)
        exipicrename.set_use_date_dir(False)
        exipicrename.set_use_duplicate(False)
        exipicrename.set_use_serial(True)

        with TemporaryDirectory() as temp_dir:

            fill_tmpdir(temp_dir, self.source_dir, self.testfiles)

            realfiles = [temp_dir + "/" + e for e in os.listdir(temp_dir)]

            exipicrename.exipicrename(realfiles)

            defaultfiles.sort()
            tmpdirfiles = os.listdir(temp_dir)
            tmpdirfiles.sort()
            self.assertEqual(defaultfiles, tmpdirfiles)