Example #1
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, [])
Example #2
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, [])
Example #3
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()])
Example #4
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, [])
Example #5
0
 def handle_check_cmd(self, conf):
     repo = app.load_repo(conf['working_dir'])
     corrupt_pics, missing_pics = app.check_pics(repo)
     exit_code = 0
     if corrupt_pics:
         print '\n'.join('CORRUPT: %s' % pic for pic in corrupt_pics)
         exit_code = 1
     if missing_pics:
         print '\n'.join('MISSING: %s' % pic for pic in missing_pics)
         exit_code = 1
     return exit_code