• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python orphan.OrphanManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pulp.server.managers.content.orphan.OrphanManager的典型用法代码示例。如果您正苦于以下问题:Python OrphanManager类的具体用法?Python OrphanManager怎么用?Python OrphanManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了OrphanManager类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_clean_non_root

    def test_clean_non_root(
            self,
            listdir,
            access,
            is_shared,
            unlink_shared,
            delete,
            config,
            rmdir,
            lexists):
        """
        Ensure that empty directories more than 1 level up from root are removed.
        """
        listdir.return_value = None
        access.return_value = True
        path = '/storage/pulp/content/test/lvl1/lvl2/thing.remove'
        storage_dir = '/storage/pulp'
        is_shared.return_value = False
        config.get.return_value = storage_dir
        lexists.return_value = True

        OrphanManager.delete_orphaned_file(path)
        rmdir.assert_has_calls(
            [
                call('/storage/pulp/content/test/lvl1/lvl2'),
                call('/storage/pulp/content/test/lvl1')
            ])
开发者ID:pulp,项目名称:pulp,代码行数:27,代码来源:test_orphan.py


示例2: test_delete_exception

    def test_delete_exception(self, is_dir, unlink, log_error):
        path = 'path-1'
        is_dir.return_value = False
        unlink.side_effect = OSError

        # test
        OrphanManager.delete(path)

        # validation
        self.assertTrue(log_error.called)
开发者ID:pulp,项目名称:pulp,代码行数:10,代码来源:test_orphan.py


示例3: test_delete_file

    def test_delete_file(self, is_file, unlink, rmtree):
        path = 'path-1'
        is_file.return_value = True

        # test
        OrphanManager.delete(path)

        # validation
        is_file.assert_called_with(path)
        unlink.assert_called_with(path)
        self.assertFalse(rmtree.called)
开发者ID:pulp,项目名称:pulp,代码行数:11,代码来源:test_orphan.py


示例4: test_path_not_exists

    def test_path_not_exists(self, is_shared, unlink_shared, delete, config, rmdir, lexists):
        lexists.return_value = False
        path = '/tmp/path-1'

        # test
        OrphanManager.delete_orphaned_file(path)

        # validation
        lexists.assert_called_once_with(path)
        self.assertFalse(is_shared.called)
        self.assertFalse(delete.called)
        self.assertFalse(rmdir.called)
        self.assertFalse(unlink_shared.called)
开发者ID:pulp,项目名称:pulp,代码行数:13,代码来源:test_orphan.py


示例5: test_delete_target_not_sibling

    def test_delete_target_not_sibling(self, delete, read_link, listdir):
        path = '/parent/links/path-1'
        content = '/NOT-SAME-PARENT/content'
        read_link.return_value = content
        listdir.return_value = []

        # test
        OrphanManager.unlink_shared(path)

        # validation
        read_link.assert_called_once_with(path)
        listdir.assert_called_once_with(os.path.dirname(path))
        delete.assert_called_once_with(path)
开发者ID:pulp,项目名称:pulp,代码行数:13,代码来源:test_orphan.py


示例6: test_delete_links_not_empty

    def test_delete_links_not_empty(self, delete, read_link, listdir):
        path = '/parent/links/path-1'
        content = '/parent/content'
        read_link.return_value = content
        listdir.return_value = ['link-2']

        # test
        OrphanManager.unlink_shared(path)

        # validation
        read_link.assert_called_once_with(path)
        listdir.assert_called_once_with(os.path.dirname(path))
        delete.assert_called_once_with(path)
开发者ID:pulp,项目名称:pulp,代码行数:13,代码来源:test_orphan.py


示例7: test_delete_dir

    def test_delete_dir(self, is_file, is_link, unlink, rmtree):
        path = 'path-1'
        is_file.return_value = False
        is_link.return_value = False

        # test
        OrphanManager.delete(path)

        # validation
        is_file.assert_called_with(path)
        is_link.assert_called_with(path)
        rmtree.assert_called_with(path)
        self.assertFalse(unlink.called)
开发者ID:pulp,项目名称:pulp,代码行数:13,代码来源:test_orphan.py


示例8: test_not_shared

    def test_not_shared(self, is_shared, unlink_shared, delete, config):
        path = '/path-1'
        storage_dir = '/storage/pulp/dir'
        is_shared.return_value = False
        config.get.return_value = storage_dir

        # test
        OrphanManager.delete_orphaned_file(path)

        # validation
        is_shared.assert_called_once_with(storage_dir, path)
        delete.assert_called_once_with(path)
        self.assertFalse(unlink_shared.called)
开发者ID:maxamillion,项目名称:pulp,代码行数:13,代码来源:test_orphan.py


示例9: test_clean_no_access

    def test_clean_no_access(self, mls, maccess, is_shared, unlink_shared, delete, config, m_rmdir):
        """
        Ensure that rmdir is not called when user does not have access to dir.
        """
        mls.return_value = None
        maccess.return_value = False
        path = '/storage/pulp/content/test/lvl1/lvl2/thing.remove'
        storage_dir = '/storage/pulp'
        is_shared.return_value = False
        config.get.return_value = storage_dir

        OrphanManager.delete_orphaned_file(path)
        self.assertFalse(m_rmdir.called)
开发者ID:aeria,项目名称:pulp,代码行数:13,代码来源:test_orphan.py


示例10: test_clean_nonempty

    def test_clean_nonempty(self, mls, maccess, is_shared, unlink_shared, delete, config, m_rmdir):
        """
        Ensure that nonempty directories are not removed.
        """
        mls.return_value = ['some', 'files']
        maccess.return_value = True
        path = '/storage/pulp/content/test/lvl1/lvl2/thing.remove'
        storage_dir = '/storage/pulp'
        is_shared.return_value = False
        config.get.return_value = storage_dir

        OrphanManager.delete_orphaned_file(path)
        self.assertFalse(m_rmdir.called)
开发者ID:aeria,项目名称:pulp,代码行数:13,代码来源:test_orphan.py


示例11: test_generate_orphans_by_type_with_unit_keys_invalid_type

 def test_generate_orphans_by_type_with_unit_keys_invalid_type(self):
     """
     Assert that when an invalid content type is passed to
     generate_orphans_by_type_with_unit_keys a MissingResource exception is raised.
     """
     self.assertRaises(
         pulp_exceptions.MissingResource,
         OrphanManager.generate_orphans_by_type_with_unit_keys('Not a type').next)
开发者ID:pombreda,项目名称:pulp,代码行数:8,代码来源:test_orphan.py


示例12: test_delete_all

    def test_delete_all(self, delete, read_link, listdir):
        path = '/parent/links/path-1'
        content = '/parent/content'
        read_link.return_value = content
        listdir.return_value = []

        # test
        OrphanManager.unlink_shared(path)

        # validation
        read_link.assert_called_once_with(path)
        listdir.assert_called_once_with(os.path.dirname(path))
        self.assertEqual(
            delete.call_args_list,
            [
                ((path,), {}),
                ((content,), {}),
            ])
开发者ID:pulp,项目名称:pulp,代码行数:18,代码来源:test_orphan.py


示例13: test_not_links_dir

    def test_not_links_dir(self, is_link):
        storage_dir = '/var/lib/pulp'
        path = os.path.join(storage_dir, 'content/shared/repo-id/OTHER/link-1')
        is_link.return_value = True

        # test
        shared = OrphanManager.is_shared(storage_dir, path)

        # validation
        self.assertFalse(shared)
开发者ID:pulp,项目名称:pulp,代码行数:10,代码来源:test_orphan.py


示例14: test_generate_orphans_by_type_with_unit_keys_invalid_type

    def test_generate_orphans_by_type_with_unit_keys_invalid_type(self, mock_get_unit_key_fields):
        """
        Assert that when an invalid content type is passed to
        generate_orphans_by_type_with_unit_keys a MissingResource exception is raised.
        """
        # simulate the type not being found
        mock_get_unit_key_fields.side_effect = ValueError

        self.assertRaises(
            pulp_exceptions.MissingResource,
            OrphanManager.generate_orphans_by_type_with_unit_keys('Not a type').next)
开发者ID:pulp,项目名称:pulp,代码行数:11,代码来源:test_orphan.py


示例15: setUp

 def setUp(self):
     super(OrphanManagerTests, self).setUp()
     content_type_db.update_database([PHONY_TYPE_1, PHONY_TYPE_2])
     self.content_root = tempfile.mkdtemp(prefix='content_orphan_manager_unittests-')
     self.orphan_manager = OrphanManager()
开发者ID:domcleal,项目名称:pulp,代码行数:5,代码来源:test_content_orphan_manager.py


示例16: OrphanManagerTests

class OrphanManagerTests(base.PulpServerTests):

    def setUp(self):
        super(OrphanManagerTests, self).setUp()
        content_type_db.update_database([PHONY_TYPE_1, PHONY_TYPE_2])
        self.content_root = tempfile.mkdtemp(prefix='content_orphan_manager_unittests-')
        self.orphan_manager = OrphanManager()

    def tearDown(self):
        super(OrphanManagerTests, self).tearDown()
        RepoContentUnit.get_collection().remove(safe=True)
        content_type_db.clean()
        if os.path.exists(self.content_root): # can be removed by delete operations
            shutil.rmtree(self.content_root)

    def number_of_files_in_content_root(self):
        if not os.path.exists(self.content_root): # can be removed by delete operations
            return 0
        contents = os.listdir(self.content_root)
        return len(contents)

    # utilities test methods ---------------------------------------------------

    def test_content_creation(self):
        self.assertTrue(self.number_of_files_in_content_root() == 0)
        content_unit = gen_content_unit(PHONY_TYPE_1.id, self.content_root)
        self.assertTrue(os.path.exists(content_unit['_storage_path']))
        self.assertTrue(self.number_of_files_in_content_root() == 1)

    # list test methods --------------------------------------------------------

    def test_list_one_orphan(self):
        orphans = self.orphan_manager.list_all_orphans()
        self.assertTrue(len(orphans) == 0)
        content_unit = gen_content_unit(PHONY_TYPE_1.id, self.content_root)
        orphans = self.orphan_manager.list_all_orphans()
        self.assertTrue(len(orphans) == 1)
        self.assertTrue(orphans[0]['_id'] == content_unit['_id'])

    def test_list_two_orphans(self):
        unit_1 = gen_content_unit(PHONY_TYPE_1.id, self.content_root)
        unit_2 = gen_content_unit(PHONY_TYPE_2.id, self.content_root)
        orphans = self.orphan_manager.list_all_orphans()
        self.assertTrue(len(orphans) == 2)

    def test_list_orphans_by_type(self):
        unit_1 = gen_content_unit(PHONY_TYPE_1.id, self.content_root)
        unit_2 = gen_content_unit(PHONY_TYPE_2.id, self.content_root)
        orphans_1 = self.orphan_manager.list_orphans_by_type(PHONY_TYPE_1.id)
        self.assertTrue(len(orphans_1) == 1)
        orphans_2 = self.orphan_manager.list_orphans_by_type(PHONY_TYPE_2.id)
        self.assertTrue(len(orphans_2) == 1)

    def test_get_orphan(self):
        unit = gen_content_unit(PHONY_TYPE_1.id, self.content_root)
        orphan = self.orphan_manager.get_orphan(PHONY_TYPE_1.id, unit['_id'])
        self.assertTrue(orphan['_id'] == unit['_id'])

    def test_get_missing_orphan(self):
        self.assertRaises(pulp_exceptions.MissingResource,
                          self.orphan_manager.get_orphan,
                          PHONY_TYPE_1.id, 'non-existent')

    def test_associated_unit(self):
        unit = gen_content_unit(PHONY_TYPE_1.id, self.content_root)
        associate_content_unit_with_repo(unit)
        orphans = self.orphan_manager.list_all_orphans()
        self.assertTrue(len(orphans) == 0)
        unassociate_content_unit_from_repo(unit)
        orphans = self.orphan_manager.list_all_orphans()
        self.assertTrue(len(orphans) == 1)

    # delete test methods ------------------------------------------------------

    def test_delete_one_orphan(self):
        unit = gen_content_unit(PHONY_TYPE_1.id, self.content_root)
        self.orphan_manager.delete_all_orphans()
        orphans = self.orphan_manager.list_all_orphans()
        self.assertTrue(len(orphans) == 0)
        self.assertTrue(self.number_of_files_in_content_root() == 0)

    def test_delete_one_orphan_with_directory(self):
        unit = gen_content_unit_with_directory(PHONY_TYPE_1.id, self.content_root)
        self.orphan_manager.delete_all_orphans()
        orphans = self.orphan_manager.list_all_orphans()
        self.assertTrue(len(orphans) == 0)
        self.assertTrue(self.number_of_files_in_content_root() == 0)

    def test_delete_by_type(self):
        unit_1 = gen_content_unit(PHONY_TYPE_1.id, self.content_root)
        unit_2 = gen_content_unit(PHONY_TYPE_2.id, self.content_root)
        self.assertTrue(self.number_of_files_in_content_root() == 2)
        self.orphan_manager.delete_orphans_by_type(PHONY_TYPE_1.id)
        orphans = self.orphan_manager.list_all_orphans()
        self.assertTrue(len(orphans) == 1)
        self.assertFalse(os.path.exists(unit_1['_storage_path']))
        self.assertTrue(os.path.exists(unit_2['_storage_path']))

    def test_delete_by_id(self):
        unit = gen_content_unit(PHONY_TYPE_1.id, self.content_root)
#.........这里部分代码省略.........
开发者ID:domcleal,项目名称:pulp,代码行数:101,代码来源:test_content_orphan_manager.py



注:本文中的pulp.server.managers.content.orphan.OrphanManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factory.consumer_agent_manager函数代码示例发布时间:2022-05-25
下一篇:
Python agent.AgentManager类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap