示例#1
0
    def test_run_restore_file_from_basket(self):
        with open(self.file_path, 'rb') as afile:
            buf = afile.read()
            self.hasher.update(buf)

        handler_file = RemoveHandler(
            logger=self.logger,
            is_basket=True,
            basket_path=self.basket,
        )
        handler_file.remove(self.file_path)
        self.assertEqual(exists(self.file_path), False)
        self.assertTrue(exists(join(self.basket, basename(self.file_path))))

        restorehandler.restore(basename(self.file_path),
                               basket_path=self.basket,
                               logger=self.logger,
                               is_replace=True)

        self.assertFalse(exists(join(self.basket, basename(self.file_path))))
        self.assertEqual(exists(self.file_path), True)
        hasher2 = hashlib.md5()
        with open(self.file_path, 'rb') as afile:
            buf = afile.read()
            hasher2.update(buf)
        self.assertEqual(hasher2.hexdigest(), self.hasher.hexdigest())
示例#2
0
 def test_run_remove_dir_to_basket(self):
     handler_dir = RemoveHandler(is_recursive=True,
                                 is_basket=True,
                                 basket_path=self.basket,
                                 logger=self.logger)
     handler_dir.remove(self.dir_path)
     self.assertEqual(exists(self.dir_path), False)
     self.assertTrue(exists(join(self.basket, basename(self.dir_path))))
示例#3
0
 def test_run_remove_file(self):
     handler_file = RemoveHandler(logger=self.logger,
                                  basket_path=self.basket,
                                  is_basket=True)
     handler_file.remove(self.file_path)
     self.assertEqual(exists(self.file_path), False)
     self.assertEqual(
         exists(join(self.basket,
                     basename(self.file_path) + "(1)")), True)
示例#4
0
 def test_run_remove_empty_dir_to_basket(self):
     handler_empty_dir = RemoveHandler(is_dir=True,
                                       is_basket=True,
                                       basket_path=self.basket,
                                       logger=self.logger)
     handler_empty_dir.remove(self.empty_dir_path)
     self.assertEqual(exists(self.empty_dir_path), False)
     self.assertEqual(
         exists(join(self.basket,
                     basename(self.empty_dir_path) + "(1)")), True)
示例#5
0
 def test_run_restore_dir_from_basket(self):
     handler_dir = RemoveHandler(is_recursive=True,
                                 is_basket=True,
                                 basket_path=self.basket,
                                 logger=self.logger)
     handler_dir.remove(self.dir_path)
     self.assertEqual(exists(self.dir_path), False)
     self.assertTrue(exists(join(self.basket, basename(self.dir_path))))
     restorehandler.restore(basename(self.dir_path),
                            basket_path=self.basket,
                            logger=self.logger,
                            is_replace=True)
     self.assertFalse(exists(join(self.basket, basename(self.dir_path))))
     self.assertEqual(exists(self.dir_path), True)
示例#6
0
 def test_run_remove_file_to_basket(self):
     handler_file = RemoveHandler(logger=self.logger, is_basket=True,
                                  symlinks=False, basket_path=self.basket,)
     handler_file.remove(self.link_to_file)
     self.assertEqual(exists(self.file_path), True)
     self.assertEqual(exists(self.link_to_file), False)
示例#7
0
 def test_run_remove_dir_to_basket(self):
     handler_dir = RemoveHandler(is_recursive=True, symlinks=False, is_basket=True,
                                 basket_path=self.basket, logger=self.logger)
     handler_dir.remove(self.link_to_dir)
     self.assertEqual(exists(self.link_to_dir), False)
     self.assertEqual(exists(self.dir_path), True)
示例#8
0
 def test_run_remove_link_empty_dir(self):
     handler_empty_dir = RemoveHandler(symlinks=False, is_dir=True, is_basket=True,
                                       basket_path=self.basket, logger=self.logger)
     handler_empty_dir.remove(self.link_to_emptydir)
     self.assertEqual(exists(self.link_to_emptydir), False)
     self.assertEqual(exists(self.empty_dir_path), True)
示例#9
0
 def test_run_remove_file(self):
     handler_file = RemoveHandler(logger=self.logger)
     handler_file.remove(self.file_path)
     self.assertEqual(exists(self.file_path), False)
示例#10
0
 def test_run_remove_dir(self):
     handler_dir = RemoveHandler(is_recursive=True, logger=self.logger)
     handler_dir.remove(self.dir_path)
     self.assertEqual(exists(self.dir_path), False)