Esempio n. 1
0
    def get_one_of_many_test(self):
        self.dvc.add(self.FOO)
        self.dvc.add(self.BAR)
        fsck_objs = Fsck(self.dvc, [self.FOO]).fsck_objs

        self.assertEqual(len(fsck_objs), 1)
        self.assertEqual(fsck_objs[0].dvc_path, self.FOO)
Esempio n. 2
0
    def by_file_test(self):
        self.dvc.add(self.FOO)
        self.dvc.add(self.BAR)
        fsck_objs = Fsck(self.dvc, [self.FOO, self.BAR]).fsck_objs

        self.assertEqual(len(fsck_objs), 2)
        for obj in fsck_objs:
            self.assertIsNone(obj.error_status)
Esempio n. 3
0
    def get_all_test(self):
        self.dvc.add(self.FOO)
        self.dvc.add(self.BAR)
        fsck_objs = Fsck(self.dvc, all=True).fsck_objs

        self.assertEqual(len(fsck_objs), 2)
        for obj in fsck_objs:
            self.assertIsNone(obj.error_status)
Esempio n. 4
0
    def defined_target_with_mismatch_test(self):
        stage_foo = self.dvc.add(self.FOO)
        self.dvc.add(self.BAR)

        for out in stage_foo.outs:
            if out.dvc_path == self.FOO:
                out.md5 = out.md5 + '1234fe'
        stage_foo.dump()

        fsck_objs = Fsck(self.dvc, [self.FOO, self.BAR]).fsck_objs
        self.assertEqual(len(fsck_objs), 2)
Esempio n. 5
0
    def physical_test(self):
        self.dvc.add(self.FOO)
        self.dvc.add(self.BAR)

        os.chmod(self.FOO, 0o777)
        os.remove(self.FOO)
        with open(self.FOO, 'w') as fd:
            fd.write('randome stuff s9dfj')

        fsck_objs = Fsck(self.dvc, physical=True).fsck_objs

        self.assertEqual(len(fsck_objs), 1)
        self.assertEqual(fsck_objs[0].dvc_path, self.FOO)
Esempio n. 6
0
    def by_timestemp_physical_test(self):
        self.dvc.add(self.FOO)
        self.dvc.add(self.BAR)

        os.chmod(self.FOO, 0o777)
        os.remove(self.FOO)
        with open(self.FOO, 'w') as fd:
            fd.write('randome stuff 39re2fwecsb nj')

        fsck_objs = Fsck(self.dvc, physical=False).fsck_objs

        self.assertEqual(len(fsck_objs), 1)
        self.assertEqual(fsck_objs[0].dvc_path, self.FOO)
Esempio n. 7
0
    def checksum_mismatch_test(self):
        stage_foo = self.dvc.add(self.FOO)
        self.dvc.add(self.BAR)

        for out in stage_foo.outs:
            if out.dvc_path == self.FOO:
                out.md5 = out.md5 + '1234fe'
        stage_foo.dump()

        fsck_objs = Fsck(self.dvc).fsck_objs
        self.assertEqual(len(fsck_objs), 1)
        self.assertEqual(fsck_objs[0].dvc_path, self.FOO)
        self.assertEqual(fsck_objs[0].error_status,
                         FsckFile.ERR_STATUS_CHECKSUM_MISMATCH)
Esempio n. 8
0
    def no_cache_file_test(self):
        stage_foo = self.dvc.add(self.FOO)
        self.dvc.add(self.BAR)

        md5 = ''
        for out in stage_foo.outs:
            if out.dvc_path == self.FOO:
                md5 = out.md5

        foo_cache_file = os.path.join(self.dvc.cache.cache_dir, md5)
        self.assertTrue(os.path.exists(foo_cache_file))

        os.chmod(foo_cache_file, 0o777)
        os.remove(foo_cache_file)
        self.assertFalse(os.path.exists(foo_cache_file))

        fsck_objs = Fsck(self.dvc).fsck_objs
        self.assertEqual(len(fsck_objs), 1)
        self.assertEqual(fsck_objs[0].dvc_path, self.FOO)
        self.assertEqual(fsck_objs[0].error_status,
                         FsckFile.ERR_STATUS_NO_CACHE_FILE)
Esempio n. 9
0
 def no_file_corruptions_test(self):
     fsck_objs = Fsck(self.dvc).fsck_objs
     self.assertEqual(len(fsck_objs), 0)