コード例 #1
0
ファイル: test_bakthat_azure.py プロジェクト: Arttii/bakthat
    def test_swift_delete_older_than(self):
        backup_res = bakthat.backup(self.test_filename, "azure", password="",
                                    profile=self.test_profile)

        #self.assertEqual(bakthat.match_filename(self.test_filename, "swift",
        #                                        profile=self.test_profile
        #                                        )[0]["filename"],
        #                 self.test_filename)

        bakthat.restore(self.test_filename, "azure",
                        profile=self.test_profile)

        restored_hash = hashlib.sha1(
            open(self.test_filename).read()).hexdigest()

        self.assertEqual(self.test_hash, restored_hash)

        #os.remove(self.test_filename)

        test_deleted = bakthat.delete_older_than(self.test_filename, "1Y",
                                                 destination="azure",
                                                 profile=self.test_profile)

        self.assertEqual(test_deleted, [])

        time.sleep(10)

        test_deleted = bakthat.delete_older_than(self.test_filename, "9s",
                                                 destination="azure",
                                                 profile=self.test_profile)

       
        key_deleted = test_deleted[0]

        self.assertEqual(key_deleted, backup_res)
コード例 #2
0
ファイル: test_bakthat.py プロジェクト: hfunai/bakthat
    def test_s3_delete_older_than(self):
        backup_res = bakthat.backup(self.test_file.name, "s3", password="")

        self.assertEqual(bakthat.match_filename(self.test_filename, "s3")[0]["filename"],
                        self.test_filename)

        bakthat.restore(self.test_filename, "s3")
        
        restored_hash = hashlib.sha1(open(self.test_filename).read()).hexdigest()
        
        self.assertEqual(self.test_hash, restored_hash)

        os.remove(self.test_filename)

        test_deleted = bakthat.delete_older_than(self.test_filename, "1Y", "s3")

        self.assertEqual(test_deleted, [])

        time.sleep(10)

        test_deleted = bakthat.delete_older_than(self.test_filename, "9s", "s3")

        key_deleted = test_deleted[0]

        self.assertEqual(key_deleted, backup_res["stored_filename"])

        self.assertEqual(bakthat.match_filename(self.test_filename), [])
コード例 #3
0
    def test_s3_delete_older_than(self):
        backup_res = bakthat.backup(self.test_file.name, "s3", password="")

        #self.assertEqual(bakthat.match_filename(self.test_filename, "s3")[0]["filename"],
        #                 self.test_filename)

        bakthat.restore(self.test_filename, "s3")

        restored_hash = hashlib.sha1(open(
            self.test_filename).read()).hexdigest()

        self.assertEqual(self.test_hash, restored_hash)

        os.remove(self.test_filename)

        test_deleted = bakthat.delete_older_than(self.test_filename,
                                                 "1Y",
                                                 destination="s3")

        self.assertEqual(test_deleted, [])

        time.sleep(10)

        test_deleted = bakthat.delete_older_than(self.test_filename,
                                                 "9s",
                                                 destination="s3")

        key_deleted = test_deleted[0]

        self.assertEqual(key_deleted.stored_filename,
                         backup_res.stored_filename)
コード例 #4
0
    def test_swift_delete_older_than(self):
        backup_res = bakthat.backup(self.test_file.name,
                                    "swift",
                                    password="",
                                    profile=self.test_profile)

        #self.assertEqual(bakthat.match_filename(self.test_filename, "swift",
        #                                        profile=self.test_profile
        #                                        )[0]["filename"],
        #                 self.test_filename)

        bakthat.restore(self.test_filename, "swift", profile=self.test_profile)

        restored_hash = hashlib.sha1(open(
            self.test_filename).read()).hexdigest()

        self.assertEqual(self.test_hash, restored_hash)

        os.remove(self.test_filename)

        test_deleted = bakthat.delete_older_than(self.test_filename,
                                                 "1Y",
                                                 "swift",
                                                 profile=self.test_profile)

        self.assertEqual(test_deleted, [])

        time.sleep(10)

        test_deleted = bakthat.delete_older_than(self.test_filename,
                                                 "9s",
                                                 "swift",
                                                 profile=self.test_profile)

        key_deleted = test_deleted[0]

        self.assertEqual(key_deleted, backup_res["stored_filename"])