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


Python RepoPublishConduit.last_publish方法代码示例

本文整理汇总了Python中pulp.plugins.conduits.repo_publish.RepoPublishConduit.last_publish方法的典型用法代码示例。如果您正苦于以下问题:Python RepoPublishConduit.last_publish方法的具体用法?Python RepoPublishConduit.last_publish怎么用?Python RepoPublishConduit.last_publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulp.plugins.conduits.repo_publish.RepoPublishConduit的用法示例。


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

示例1: RepoPublishConduitTests

# 需要导入模块: from pulp.plugins.conduits.repo_publish import RepoPublishConduit [as 别名]
# 或者: from pulp.plugins.conduits.repo_publish.RepoPublishConduit import last_publish [as 别名]
class RepoPublishConduitTests(base.PulpServerTests):

    def clean(self):
        super(RepoPublishConduitTests, self).clean()

        mock_plugins.reset()
        model.Repository.objects.delete()
        model.Distributor.objects.delete()

    @mock.patch('pulp.server.controllers.distributor.model.Repository.objects')
    def setUp(self, mock_repo_qs):
        super(RepoPublishConduitTests, self).setUp()
        mock_plugins.install()
        manager_factory.initialize()

        # Populate the database with a repo with units
        dist_controller.add_distributor('repo-1', 'mock-distributor', {}, True,
                                        distributor_id='dist-1')

        self.conduit = RepoPublishConduit('repo-1', 'dist-1')

    def tearDown(self):
        super(RepoPublishConduitTests, self).tearDown()
        mock_plugins.reset()

    def test_str(self):
        """
        Makes sure the __str__ implementation doesn't crash.
        """
        str(self.conduit)

    def test_last_publish(self):
        """
        Tests retrieving the last publish time in both the unpublish and previously published cases.
        """

        # Test - Unpublished
        unpublished = self.conduit.last_publish()
        self.assertTrue(unpublished is None)

        # Setup - Previous publish
        last_publish = datetime.datetime(2015, 4, 29, 20, 23, 56, 0)
        repo_dist = model.Distributor.objects.get_or_404(repo_id='repo-1')
        repo_dist['last_publish'] = last_publish
        repo_dist.save()

        # Test - Last publish
        found = self.conduit.last_publish()
        self.assertTrue(isinstance(found, datetime.datetime))  # check returned format

        self.assertEqual(found.tzinfo, dateutils.utc_tz())
        self.assertEqual(repo_dist['last_publish'], found.replace(tzinfo=None))

    @mock.patch('pulp.plugins.conduits.repo_publish.model.Distributor.objects')
    def test_last_publish_with_error(self, m_dist_qs):
        """
        Test the handling of an error getting last_publish information.
        """
        m_dist_qs.only.return_value.get_or_404.side_effect = exceptions.MissingResource
        self.assertRaises(DistributorConduitException, self.conduit.last_publish)
开发者ID:maxamillion,项目名称:pulp,代码行数:62,代码来源:test_repo_publish.py

示例2: RepoPublishConduitTests

# 需要导入模块: from pulp.plugins.conduits.repo_publish import RepoPublishConduit [as 别名]
# 或者: from pulp.plugins.conduits.repo_publish.RepoPublishConduit import last_publish [as 别名]
class RepoPublishConduitTests(base.PulpServerTests):

    def clean(self):
        super(RepoPublishConduitTests, self).clean()

        mock_plugins.reset()
        model.Repository.drop_collection()
        RepoDistributor.get_collection().remove()

    @mock.patch('pulp.server.managers.repo.importer.model.Repository.objects')
    def setUp(self, mock_repo_qs):
        super(RepoPublishConduitTests, self).setUp()
        mock_plugins.install()
        manager_factory.initialize()

        self.distributor_manager = manager_factory.repo_distributor_manager()

        # Populate the database with a repo with units
        self.distributor_manager.add_distributor('repo-1', 'mock-distributor', {}, True,
                                                 distributor_id='dist-1')

        self.conduit = RepoPublishConduit('repo-1', 'dist-1')

    def tearDown(self):
        super(RepoPublishConduitTests, self).tearDown()
        mock_plugins.reset()

    def test_str(self):
        """
        Makes sure the __str__ implementation doesn't crash.
        """
        str(self.conduit)

    def test_last_publish(self):
        """
        Tests retrieving the last publish time in both the unpublish and previously published cases.
        """

        # Test - Unpublished
        unpublished = self.conduit.last_publish()
        self.assertTrue(unpublished is None)

        # Setup - Previous publish
        last_publish = datetime.datetime(2015, 4, 29, 20, 23, 56, 0)
        repo_dist = RepoDistributor.get_collection().find_one({'repo_id': 'repo-1'})
        repo_dist['last_publish'] = last_publish
        RepoDistributor.get_collection().save(repo_dist, safe=True)

        # Test - Last publish
        found = self.conduit.last_publish()
        self.assertTrue(isinstance(found, datetime.datetime))  # check returned format
        self.assertEqual(repo_dist['last_publish'], found)

    @mock.patch('pulp.plugins.conduits.repo_publish.RepoDistributor')
    def test_last_publish_with_error(self, mock_dist):
        """
        Test the handling of an error getting last_publish information.
        """
        mock_dist.get_collection().find_one.return_value = None
        self.assertRaises(DistributorConduitException, self.conduit.last_publish)
开发者ID:nbetm,项目名称:pulp,代码行数:62,代码来源:test_repo_publish.py

示例3: RepoPublishConduitTests

# 需要导入模块: from pulp.plugins.conduits.repo_publish import RepoPublishConduit [as 别名]
# 或者: from pulp.plugins.conduits.repo_publish.RepoPublishConduit import last_publish [as 别名]
class RepoPublishConduitTests(base.PulpServerTests):

    def clean(self):
        super(RepoPublishConduitTests, self).clean()

        mock_plugins.reset()

        Repo.get_collection().remove()
        RepoDistributor.get_collection().remove()

    def setUp(self):
        super(RepoPublishConduitTests, self).setUp()
        mock_plugins.install()
        manager_factory.initialize()

        self.repo_manager = manager_factory.repo_manager()
        self.distributor_manager = manager_factory.repo_distributor_manager()

        # Populate the database with a repo with units
        self.repo_manager.create_repo('repo-1')
        self.distributor_manager.add_distributor('repo-1', 'mock-distributor', {}, True, distributor_id='dist-1')

        self.conduit = RepoPublishConduit('repo-1', 'dist-1')

    def test_str(self):
        """
        Makes sure the __str__ implementation doesn't crash.
        """
        str(self.conduit)

    def test_last_publish(self):
        """
        Tests retrieving the last publish time in both the unpublish and previously published cases.
        """

        # Test - Unpublished
        unpublished = self.conduit.last_publish()
        self.assertTrue(unpublished is None)

        # Setup - Previous publish
        last_publish = datetime.datetime.now()
        repo_dist = RepoDistributor.get_collection().find_one({'repo_id' : 'repo-1'})
        repo_dist['last_publish'] = dateutils.format_iso8601_datetime(last_publish)
        RepoDistributor.get_collection().save(repo_dist, safe=True)

        # Test - Last publish
        found = self.conduit.last_publish()
        self.assertTrue(isinstance(found, datetime.datetime)) # check returned format
        self.assertEqual(repo_dist['last_publish'], dateutils.format_iso8601_datetime(found))

    @mock.patch('pulp.server.managers.repo.publish.RepoPublishManager.last_publish')
    def test_last_publish_with_error(self, mock_call):
        # Setup
        mock_call.side_effect = Exception()

        # Test
        self.assertRaises(DistributorConduitException, self.conduit.last_publish)
开发者ID:fdammeke,项目名称:pulp,代码行数:59,代码来源:test_repo_publish_conduit.py

示例4: _init_publisher

# 需要导入模块: from pulp.plugins.conduits.repo_publish import RepoPublishConduit [as 别名]
# 或者: from pulp.plugins.conduits.repo_publish.RepoPublishConduit import last_publish [as 别名]
    def _init_publisher(self):

        repo = Repository(self.repo_id, working_dir=self.working_dir)
        self.repo = repo

        conduit = RepoPublishConduit(repo.id, YUM_DISTRIBUTOR_ID)
        conduit.last_publish = mock.Mock(return_value=None)
        conduit.get_repo_scratchpad = mock.Mock(return_value={})

        config_defaults = {'http': True,
                           'https': True,
                           'relative_url': None,
                           'http_publish_dir': os.path.join(self.published_dir, 'http'),
                           'https_publish_dir': os.path.join(self.published_dir, 'https')}
        config = PluginCallConfiguration(None, None)
        config.default_config.update(config_defaults)

        self.publisher = publish.BaseYumRepoPublisher(repo, conduit, config, YUM_DISTRIBUTOR_ID,
                                                      working_dir=self.working_dir)
        self.publisher.get_checksum_type = mock.Mock(return_value=None)

        # mock out the repomd_file_context, so _publish_<step> can be called
        # outside of the publish() method
        self.publisher.repomd_file_context = mock.MagicMock()
        self.publisher.all_steps = mock.MagicMock()
开发者ID:dkliban,项目名称:pulp_rpm,代码行数:27,代码来源:test_publish.py


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