Exemplo n.º 1
0
    def test_backup_contains(self):
        backup_path = path.join(self.tmpdir, "backup")
        test_backup = backup.Backup(backup_path)
        for evt in walk.step_item(self.tmpdir, "data"):
            test_backup.store_event(evt)

        self.assertTrue("62a837970950bf34fb0c" "401c39cd3c0d373f0a7a" in test_backup)
        self.assertTrue("62a837970950bf34fb0c" "00000000000000000000" not in test_backup)
Exemplo n.º 2
0
    def test_backup_skip_existing(self):
        backup_path = path.join(self.tmpdir, "backup")

        f2_sha = "e8", "c3c333536348ba9c1822930ace36c506ef168d"
        os.makedirs(path.join(backup_path, f2_sha[0]))
        with open(path.join(backup_path, f2_sha[0], f2_sha[1]), "wb") as f:
            f.write("something else")

        test_backup = backup.Backup(backup_path)
        for evt in walk.step_item(self.tmpdir, "data"):
            test_backup.store_event(evt)

        with open(path.join(backup_path, f2_sha[0], f2_sha[1]), "rb") as f:
            self.assertEqual(f.read(), "something else")
Exemplo n.º 3
0
    def test_backup(self):
        backup_path = path.join(self.tmpdir, "backup")

        test_backup = backup.Backup(backup_path)
        for evt in walk.step_item(self.tmpdir, "data"):
            test_backup.store_event(evt)

        f1_sha = "62", "a837970950bf34fb0c401c39cd3c0d373f0a7a"
        f2_sha = "e8", "c3c333536348ba9c1822930ace36c506ef168d"
        f3_sha = "1d", "e35ef0e3d36a9a753e459a9471fae8b909f048"
        self.assertEqual(set(os.listdir(backup_path)), set([f1_sha[0], f2_sha[0], f3_sha[0]]))

        self.assertEqual(os.listdir(path.join(backup_path, f1_sha[0])), [f1_sha[1]])
        with open(path.join(backup_path, f1_sha[0], f1_sha[1]), "rb") as f:
            self.assertEqual(f.read(), "file one")

        self.assertEqual(os.listdir(path.join(backup_path, f2_sha[0])), [f2_sha[1]])
        with open(path.join(backup_path, f2_sha[0], f2_sha[1]), "rb") as f:
            self.assertEqual(f.read(), "file two")

        self.assertEqual(os.listdir(path.join(backup_path, f3_sha[0])), [f3_sha[1]])
        with open(path.join(backup_path, f3_sha[0], f3_sha[1]), "rb") as f:
            self.assertEqual(f.read(), "file three")