Пример #1
0
    def test_merge_repos(self):
        target = new_mock_repo('/target/repo', num_pics=14)

        pathA = '/other/repoA'
        repoA = new_mock_repo(pathA, num_pics=2)
        pathB = '/other/repoB'
        repoB = new_mock_repo(pathB, num_pics=26)

        target = app.merge_repos(target, pathA, pathB)

        for pic in repoA.index.iterpics():
            self.assertIn(pic, target.index.pics())
        for pic in repoB.index.iterpics():
            self.assertIn(pic, target.index.pics())
        self.assertEqual(len(target.index), 42)
Пример #2
0
    def test_empty_repo(self):
        empty_repo = new_mock_repo('/basedir/repo/', num_pics=0)

        corrupt, missing = app.check_pics(empty_repo)

        self.assertSequenceEqual(corrupt, [])
        self.assertSequenceEqual(missing, [])
Пример #3
0
    def test_add_to_empty_repo(self, mock_exists):
        rep = new_mock_repo(self.path, num_pics=0)  # new empty repo
        pics = ['DSC_%04i' % i for i in range(15)]  # pictures to be added
        rep = app.add_pics(rep, pics, process=False)

        for pic in pics:
            self.assertIn(pic, rep.index)
        self.assertEqual(len(rep.index), len(pics))
Пример #4
0
    def test_load(self):
        path = "/test/path"
        rep_saved = new_mock_repo(path, num_pics=11)
        rep_loaded = app.load_repo(path)

        self.assertEqual(rep_loaded.connector.url.path, path)
        self.assertEqual(rep_loaded.index, rep_saved.index)
        self.assertEqual(rep_loaded.config, rep_saved.config)
Пример #5
0
    def test_all_ok(self):
        rep = new_mock_repo('/basedir/repo/', num_pics=10)
        rep = self.populate_picture_buffers(rep)

        corrupt, missing = app.check_pics(rep)

        self.assertSequenceEqual(corrupt, [])
        self.assertSequenceEqual(missing, [])
Пример #6
0
    def test_migrate_repo(self):
        path = '/basedir/repo/'
        repo_old = new_mock_repo(path, num_pics=10)
        repo_old.config['index.format_version'] = 0
        with MockConnector.from_string(path).connected():
            repo_old.save_config_to_disk()
        repo_new = app.migrate_repo(repo_old)

        self.assertEqual(repo_new.config['index.format_version'],
                         repo.INDEX_FORMAT_VERSION)#
Пример #7
0
    def test_append_to_repo(self, mock_exists):
        rep = new_mock_repo(self.path, num_pics=11)  # new preloaded reppo
        old_pics = [pic.filename for pic in rep.index.iterpics()]
        new_pics = ['DSC_%04i' % i for i in range(5)]  # pictures to be added
        rep = app.add_pics(rep, new_pics, process=False)

        for pic in new_pics:
            self.assertIn(pic, rep.index)
        for pic in old_pics:
            self.assertIn(pic, rep.index)
        self.assertEqual(len(rep.index), len(old_pics) + len(new_pics))
Пример #8
0
    def test_missing_pics(self):
        rep = new_mock_repo('/path/to/missingpics/repo', num_pics=31)
        def raise_oserror(*args):
            raise OSError
        rep.connector.open = raise_oserror

        corrupt, missing = app.check_pics(rep)

        self.assertSequenceEqual(corrupt, [])
        self.assertSequenceEqual(missing, [pic.filename
                                           for pic in rep.index.pics()])
Пример #9
0
    def test_corrupted_pics(self):
        rep = new_mock_repo('/basedir/repo/', num_pics=31)
        rep = self.populate_picture_buffers(rep)
        corrupted = rep.index.pics()[::3]
        for pic in corrupted:
            pic.checksum = 'wrong checksum!'

        corrupt, missing = app.check_pics(rep)

        self.assertSequenceEqual(corrupt, [pic.filename for pic in corrupted])
        self.assertSequenceEqual(missing, [])
Пример #10
0
    def test_remove_pics(self):
        rep = new_mock_repo(self.path, num_pics=25)
        keep = [pic.filename for pic in rep.index.pics()[::2]]  # 0,2,4,6,... 
        remove = [pic.filename for pic in rep.index.pics()[1::2]]  # 1,3,5,7,...
        rep = app.remove_pics(rep, remove)

        for pic in remove:
            self.assertNotIn(pic, rep.index)
            self.assertTrue(self.connector.removed(pic))
        for pic in keep:
            self.assertIn(pic, rep.index)
            self.assertFalse(self.connector.removed(pic))
        self.assertEqual(len(rep.index), len(keep))
Пример #11
0
 def setUp(self):
     self.repo = new_mock_repo("test/path", num_pics=13)
Пример #12
0
    def setUp(self):
        self.repo = new_mock_repo('/repo/path/')

        self.backupA_path = '/backupA'
        self.backupB_path = '/backupB'
Пример #13
0
 def setUp(self):
     self.origin_path = '/orig/path/foorepo'
     self.origin = new_mock_repo(self.origin_path, num_pics=17)
     self.clone_basepath = '/clone/path'
     self.clone_path = os.path.join(self.clone_basepath, 'foorepo')
Пример #14
0
 def setUp(self):
     path = '/basedir/repo/'
     self.repo = new_mock_repo(path, num_pics=31)