当前位置: 首页>>代码示例>>Python>>正文


Python orphan.OrphanManager类代码示例

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


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


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