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


Python MigrationModule._add_agent_queues方法代码示例

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


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

示例1: test_add_agent_queues_cat_only

# 需要导入模块: from pulp.server.db.migrate.models import MigrationModule [as 别名]
# 或者: from pulp.server.db.migrate.models.MigrationModule import _add_agent_queues [as 别名]
    def test_add_agent_queues_cat_only(self, fake_get):
        fake_collection = Mock()
        fake_collection.find = Mock(return_value=[{'id': 'dog'}, {'id': 'cat'}])
        fake_get.return_value = fake_collection
        fake_broker = Mock()
        fake_broker.getQueue.side_effect = [None, Mock()]

        # test
        migration = MigrationModule(MIGRATION)._module
        migration._add_agent_queues(fake_broker)

        fake_broker.getQueue.assert_any('pulp.agent.dog')
        fake_broker.getQueue.assert_any('pulp.agent.cat')
        fake_broker.addQueue.assert_calle_with('pulp.agent.cat')
开发者ID:jbennett7,项目名称:pulp,代码行数:16,代码来源:test_migration_0009.py

示例2: TestMigration

# 需要导入模块: from pulp.server.db.migrate.models import MigrationModule [as 别名]
# 或者: from pulp.server.db.migrate.models.MigrationModule import _add_agent_queues [as 别名]
class TestMigration(TestCase):

    def setUp(self):
        # Remove dependencies on qpidtoollibs and qpid.messaging
        self.migration = MigrationModule(MIGRATION)._module
        if self.migration.QPIDTOOLLIBS_AVAILABLE:
            self.broker = self.migration.BrokerAgent
        if self.migration.QPID_MESSAGING_AVAILABLE:
            self.connection = self.migration.Connection

        self.qpidtoollibs = self.migration.QPIDTOOLLIBS_AVAILABLE
        self.qpid_messaging = self.migration.QPID_MESSAGING_AVAILABLE
        self.migration.QPIDTOOLLIBS_AVAILABLE = True
        self.migration.QPID_MESSAGING_AVAILABLE = True
        self.migration.BrokerAgent = Mock()
        self.migration.Connection = Mock()

    def tearDown(self):
        self.migration.QPIDTOOLLIBS_AVAILABLE = self.qpidtoollibs
        self.migration.QPID_MESSAGING_AVAILABLE = self.qpid_messaging
        if self.migration.QPIDTOOLLIBS_AVAILABLE:
            self.migration.BrokerAgent = self.broker
        if self.migration.QPID_MESSAGING_AVAILABLE:
            self.migration.Connection = self.connection

    @patch(MIGRATION + '._migrate_reply_queue')
    @patch(MIGRATION + '._migrate_agent_queues')
    @patch(MIGRATION + '.pulp_conf', PULP_CONF)
    def test_migrate(self, fake_migrate_agent_queues, fake_migrate_reply_queue):
        # test
        self.migration.migrate()

        # validation
        self.migration.Connection.assert_called_with(
            host='myhost',
            port=1234,
            transport='tcp',
            reconnect=False,
            ssl_certfile='TEST-CERTIFICATE',
            ssl_skip_hostname_check=True)

        self.migration.Connection().attach.assert_called_with()
        self.migration.BrokerAgent.assert_called_with(self.migration.Connection())
        fake_migrate_reply_queue.assert_called_with(self.migration.BrokerAgent())
        fake_migrate_agent_queues.assert_called_with(self.migration.BrokerAgent())
        self.migration.Connection().detach.assert_called_with()

    @patch(MIGRATION + '._migrate_reply_queue')
    @patch(MIGRATION + '._migrate_agent_queues')
    @patch(MIGRATION + '.pulp_conf')
    def test_migrate_not_qpid(self, fake_conf, fake_migrate_agent_queues,
                              fake_migrate_reply_queue,):

        fake_conf.get.return_value = 'not-qpid'

        # test
        self.migration.migrate()

        # validation
        self.assertFalse(self.migration.Connection.called)
        self.assertFalse(self.migration.BrokerAgent.called)
        self.assertFalse(fake_migrate_reply_queue.called)
        self.assertFalse(fake_migrate_agent_queues.called)

    @patch(MIGRATION + '._del_agent_queues')
    @patch(MIGRATION + '._add_agent_queues')
    def test_migrate_agent_queues(self, fake_add_agent_queues, fake_del_agent_queues):
        fake_broker = Mock()

        # test
        self.migration._migrate_agent_queues(fake_broker)

        # validation
        fake_add_agent_queues.assert_called_with(fake_broker)
        fake_del_agent_queues.assert_called_with(fake_broker)

    @patch('pulp.server.db.model.consumer.Consumer.get_collection')
    def test_add_agent_queues(self, fake_get):
        fake_collection = Mock()
        fake_collection.find = Mock(return_value=[{'id': 'dog'}, {'id': 'cat'}])
        fake_get.return_value = fake_collection
        fake_broker = Mock()
        fake_broker.getQueue.side_effect = [None, None]

        # test
        self.migration._add_agent_queues(fake_broker)

        fake_broker.getQueue.assert_any('pulp.agent.dog')
        fake_broker.getQueue.assert_any('pulp.agent.cat')
        fake_broker.addQueue.assert_any('pulp.agent.dog')
        fake_broker.addQueue.assert_any('pulp.agent.cat')

    @patch('pulp.server.db.model.consumer.Consumer.get_collection')
    def test_add_agent_queues_cat_only(self, fake_get):
        fake_collection = Mock()
        fake_collection.find = Mock(return_value=[{'id': 'dog'}, {'id': 'cat'}])
        fake_get.return_value = fake_collection
        fake_broker = Mock()
        fake_broker.getQueue.side_effect = [None, Mock()]

#.........这里部分代码省略.........
开发者ID:ipanova,项目名称:pulp,代码行数:103,代码来源:test_0009_qpid_queues.py


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