Ejemplo n.º 1
0
    def test_reverse(self):
        '''to make sure that the golden would not change - test wise versa'''

        sys.argv = [
            '-v', '-w',
            os.path.join('tst', 'golden'), '-g',
            os.path.join('tst', 'work'), "-p"
        ]

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(16, len(all_files), "total files")
        # print len(all_files), all_files

        all_files = duplicates.get_all_files("tst/work")
        self.assertEqual(9, len(all_files), "total files")
        # print len(all_files), all_files

        # 1. find all duplicates
        # with self.assertRaises(duplicates.GreatSuccess):
        # duplicates.main()
        duplicates.main()

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(12, len(all_files), "total files")

        all_files = duplicates.get_all_files("tst/work")
        # print len(all_files), all_files
        self.assertEqual(9, len(all_files), "total files")

        all_files = duplicates.get_all_files("tst/golden")
        # print len(all_files), all_files
        self.assertEqual(1, len(all_files), "total files")
Ejemplo n.º 2
0
    def test_duplicates_similar_names2(self):
        '''similar names the other way around'''

        sys.argv = [
            '-v', '-g',
            os.path.join('tst copy', ''), '-w',
            os.path.join('tst', ''), "-p"
        ]

        shutil.rmtree("tst copy", ignore_errors=True)
        shutil.copytree(
            "sample",
            "tst copy",
        )

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(16, len(all_files), "total files")
        all_files = duplicates.get_all_files("tst copy")
        self.assertEqual(16, len(all_files), "total files")

        duplicates.main()

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(0, len(all_files), "total files")

        all_files = duplicates.get_all_files("tst copy")
        self.assertEqual(16, len(all_files), "total files")
Ejemplo n.º 3
0
    def test_straight(self):
        '''test that duplicates.py finds all the duplicates in the sample folder'''

        sys.argv = [
            '-v', '-g',
            os.path.join('tst', 'golden'), '-w',
            os.path.join('tst', 'work'), '--purge'
        ]

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(16, len(all_files), "total files")
        # print len(all_files), all_files

        # 1. find all duplicates
        # with self.assertRaises(duplicates.GreatSuccess):
        # duplicates.main()
        duplicates.main()

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(8, len(all_files), "total files")

        all_files = duplicates.get_all_files("tst/work")
        # print len(all_files), all_files
        self.assertEqual(1, len(all_files), "total files")

        all_files = duplicates.get_all_files("tst/golden")
        # print len(all_files), all_files
        self.assertEqual(5, len(all_files), "total files")
Ejemplo n.º 4
0
    def test_date2(self):
        '''make sure to remove most recent'''

        sys.argv = [
            '-v', '-w',
            os.path.join('tst', ''), '-g',
            os.path.join('tst', 'golden'), "-p"
        ]

        # change modify time
        tfn = 'tst/work/1/.new.jpg'
        self.assertTrue(os.path.isfile(tfn), '%s eists' % (tfn))
        mtime = os.path.getmtime(tfn)
        # print mtime
        os.utime(tfn, (mtime * 2, mtime * 2))
        # os.path.getmtime('tst/golden/duplicate copy.jpg')

        # with self.assertRaises(duplicates.GreatSuccess):
        # duplicates.main()
        duplicates.main()

        self.assertFalse(os.path.isfile(tfn), '%s eists' % (tfn))

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(7, len(all_files), "total files after")
Ejemplo n.º 5
0
    def test_date1(self):
        '''make sure we preserve the oldest'''

        sys.argv = [
            '-v', '-w',
            os.path.join('tst', ''), '-g',
            os.path.join('tst', 'golden'), '-p'
        ]

        # change modify time
        tfn = 'tst/work/1/.new.jpg'
        self.assertTrue(os.path.isfile(tfn), '%s eists' % (tfn))
        # mtime = os.path.getmtime(tfn)
        # print mtime
        os.utime(tfn, (0, 0))
        # os.path.getmtime('tst/golden/duplicate copy.jpg')

        # find all duplicates
        # with self.assertRaises(duplicates.GreatSuccess):
        # duplicates.main()
        duplicates.main()

        self.assertTrue(os.path.isfile(tfn), '%s eists' % (tfn))

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(7, len(all_files), "total files after")
Ejemplo n.º 6
0
    def test_path2(self):
        '''what if golden is in work'''

        sys.argv = [
            '-v', '-w',
            os.path.join('tst', ''), '-g',
            os.path.join('tst', 'golden'), "-p"
        ]

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(16, len(all_files), "total files before")

        # find all duplicates
        # with self.assertRaises(duplicates.GreatSuccess):
        # duplicates.main()
        duplicates.main()

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(7, len(all_files), "total files after")

        all_files = duplicates.get_all_files("tst/work")
        self.assertEqual(1, len(all_files), "files in work")

        all_files = duplicates.get_all_files("tst/golden")
        self.assertEqual(5, len(all_files), "files in work")
Ejemplo n.º 7
0
    def test_no_golden(self):
        '''make sure we keep one good version in work if golden is not given'''

        sys.argv = ['-v', '-w', os.path.join('tst', ''), "-p"]

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(16, len(all_files), "total files")

        # 1. find all duplicates
        # with self.assertRaises(duplicates.GreatSuccess):
        # duplicates.main()
        duplicates.main()

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(6, len(all_files), "total files")
Ejemplo n.º 8
0
    def test_path_same(self):
        '''what if work is in golden (same path)'''

        sys.argv = [
            '-v', '-g',
            os.path.join('tst', ''), '-w',
            os.path.join('tst', '')
        ]

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(16, len(all_files), "total files")

        # find all duplicates
        with self.assertRaises(duplicates.ArgumentCheck):
            duplicates.main()

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(16, len(all_files), "total files")
Ejemplo n.º 9
0
    def test_date1(self):
        """Make sure we preserve the oldest"""

        sys.argv = [
            '-v', '-w',
            os.path.join('tst', ''), '-g',
            os.path.join('tst', 'golden'), '-p'
        ]

        # change modify time
        tfn = 'tst/work/1/.new.jpg'
        self.assertTrue(os.path.isfile(tfn), '%s exists' % tfn)
        os.utime(tfn, (0, 0))
        duplicates.main()

        self.assertTrue(os.path.isfile(tfn), '%s exists' % tfn)

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(7, len(all_files), "total files after")
Ejemplo n.º 10
0
    def test_date2(self):
        """Make sure to remove most recent"""

        sys.argv = [
            '-v', '-w',
            os.path.join('tst', ''), '-g',
            os.path.join('tst', 'golden'), "-p"
        ]

        # change modify time
        tfn = 'tst/work/1/.new.jpg'
        self.assertTrue(os.path.isfile(tfn), '%s exists' % tfn)
        file_time = os.path.getmtime(tfn)
        os.utime(tfn, (file_time * 2, file_time * 2))
        duplicates.main()

        self.assertFalse(os.path.isfile(tfn), '%s exists' % tfn)

        all_files = duplicates.get_all_files("tst")
        self.assertEqual(7, len(all_files), "total files after")