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


Python fixtures.MockPatch方法代码示例

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


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

示例1: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestServerTestCase, self).setUp()
        self.conf = self.useFixture(oslo_fixture.Config(config.cfg.CONF))
        self.conf.config(group="haproxy_amphora", base_path='/var/lib/octavia')
        self.conf.config(group="controller_worker",
                         loadbalancer_topology=consts.TOPOLOGY_SINGLE)
        self.conf.load_raw_values(project='fake_project')
        self.conf.load_raw_values(prog='fake_prog')
        self.useFixture(fixtures.MockPatch(
            'oslo_config.cfg.find_config_files',
            return_value=[AMP_AGENT_CONF_PATH]))
        with mock.patch('distro.id',
                        return_value='ubuntu'):
            self.ubuntu_test_server = server.Server()
            self.ubuntu_app = self.ubuntu_test_server.app.test_client()

        with mock.patch('distro.id',
                        return_value='centos'):
            self.centos_test_server = server.Server()
            self.centos_app = self.centos_test_server.app.test_client() 
开发者ID:openstack,项目名称:octavia,代码行数:22,代码来源:test_server.py

示例2: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestUndercloudInstall, self).setUp()

        self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
        self.conf.config(container_images_file='/home/stack/foo.yaml')
        self.conf.set_default('output_dir', '/home/stack')
        # setting this so we don't have to mock get_local_timezone everywhere
        self.conf.set_default('undercloud_timezone', 'UTC')
        # don't actually load config from ~/undercloud.conf
        self.mock_config_load = self.useFixture(
            fixtures.MockPatch('tripleoclient.utils.load_config'))
        # Get the command object to test
        app_args = mock.Mock()
        app_args.verbose_level = 1
        self.cmd = undercloud.InstallUndercloud(self.app, app_args)

    # TODO(cjeanner) drop once we have proper oslo.privsep 
开发者ID:openstack,项目名称:python-tripleoclient,代码行数:19,代码来源:test_install_upgrade.py

示例3: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestLUEnt, self).setUp()
        self.mock_feed_get = self.useFixture(fixtures.MockPatch(
            'pypowervm.wrappers.storage.LUEnt.get')).mock
        self.mock_feed_get.return_value = self.entries
        self.tier = mock.Mock(spec=stor.Tier, get=mock.Mock(
            return_value=self.entries))
        # Mock out each LUEnt's .delete so I can know I called the right ones.
        for luent in self.entries:
            luent.delete = mock.Mock()
        # This image LU...
        self.img_lu = self.entries[4]
        # ...backs these three linked clones
        self.clone1 = self.entries[9]
        self.clone2 = self.entries[11]
        self.clone3 = self.entries[21]
        self.orig_len = len(self.entries) 
开发者ID:powervm,项目名称:pypowervm,代码行数:19,代码来源:test_storage.py

示例4: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestPanelFunction, self).setUp()

        self.adpt = self.useFixture(pvm_fx.AdapterFx()).adpt

        # Make it easier to validate job params: create_job_parameter returns a
        # simple 'name=value' string.
        mock_crt_jparm = self.useFixture(fixtures.MockPatch(
            'pypowervm.wrappers.job.Job.create_job_parameter')).mock
        mock_crt_jparm.side_effect = (
            lambda name, value, cdata=False: '%s=%s' % (name, value))

        # Patch Job.wrap to return a mocked Job wrapper
        mock_job = mock.Mock()
        self.useFixture(fixtures.MockPatch(
            'pypowervm.wrappers.job.Job.wrap')).mock.return_value = mock_job
        self.run_job = mock_job.run_job 
开发者ID:powervm,项目名称:pypowervm,代码行数:19,代码来源:test_ibmi.py

示例5: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestPower, self).setUp()

        self.adpt = self.useFixture(fx.AdapterFx()).adpt

        # Make it easier to validate job params: create_job_parameter returns a
        # simple 'name=value' string.
        mock_crt_jparm = self.useFixture(fixtures.MockPatch(
            'pypowervm.wrappers.job.Job.create_job_parameter')).mock
        mock_crt_jparm.side_effect = (
            lambda name, value, cdata=False: '%s=%s' % (name, value))

        # Patch Job.wrap to return a mocked Job wrapper
        mock_job = mock.Mock()
        self.useFixture(fixtures.MockPatch(
            'pypowervm.wrappers.job.Job.wrap')).mock.return_value = mock_job
        self.run_job = mock_job.run_job 
开发者ID:powervm,项目名称:pypowervm,代码行数:19,代码来源:test_power.py

示例6: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestVM, self).setUp()
        self.apt = self.useFixture(pvm_fx.AdapterFx(
            traits=pvm_fx.LocalPVMTraits)).adpt
        self.apt.helpers = [pvm_log.log_helper]

        self.san_lpar_name = self.useFixture(fixtures.MockPatch(
            'pypowervm.util.sanitize_partition_name_for_api')).mock
        self.san_lpar_name.side_effect = lambda name: name

        lpar_http = pvmhttp.load_pvm_resp(LPAR_HTTPRESP_FILE, adapter=self.apt)
        self.assertNotEqual(lpar_http, None,
                            "Could not load %s " %
                            LPAR_HTTPRESP_FILE)

        self.resp = lpar_http.response 
开发者ID:openstack,项目名称:nova-powervm,代码行数:18,代码来源:test_vm.py

示例7: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestNotifications, self).setUp()

        self.conf_override(
            notifications_driver='monasca_api.common.repositories.sqla.'
                                 'notifications_repository:NotificationsRepository',
            group='repositories')

        self.notifications_repo_mock = self.useFixture(fixtures.MockPatch(
            'monasca_api.common.repositories.sqla.notifications_repository.NotificationsRepository'
        )).mock

        self.notifications_type_repo_mock = self.useFixture(fixtures.MockPatch(
            'monasca_api.common.repositories.sqla.'
            'notification_method_type_repository.NotificationMethodTypeRepository'
        )).mock

        self.notification_resource = notifications.Notifications()
        self.app.add_route(
            '/v2.0/notification-methods', self.notification_resource)
        self.app.add_route(
            '/v2.0/notification-methods/{notification_method_id}', self.notification_resource) 
开发者ID:openstack,项目名称:monasca-api,代码行数:24,代码来源:test_notifications.py

示例8: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestMetrics, self).setUp()

        self.useFixture(fixtures.MockPatch(
            'monasca_api.common.messaging.kafka_publisher.KafkaPublisher'
        ))
        self.metrics_repo_mock = self.useFixture(fixtures.MockPatch(
            'monasca_api.common.repositories.influxdb.metrics_repository.MetricsRepository'
        )).mock

        # [messaging]
        self.conf_override(
            driver='monasca_api.common.messaging.'
                   'kafka_publisher:KafkaPublisher',
            group='messaging')

        self.metrics_resource = metrics.Metrics()

        self.app.add_route('/v2.0/metrics',
                           self.metrics_resource) 
开发者ID:openstack,项目名称:monasca-api,代码行数:22,代码来源:test_metrics.py

示例9: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestAlarmsStateHistory, self).setUp()

        self.useFixture(fixtures.MockPatch(
            'monasca_api.common.repositories.sqla.'
            'alarms_repository.AlarmsRepository'))
        self.useFixture(InfluxClientAlarmHistoryResponseFixture(
            'monasca_api.common.repositories.influxdb.'
            'metrics_repository.client.InfluxDBClient'))

        self.alarms_resource = alarms.AlarmsStateHistory()
        self.app.add_route(
            '/v2.0/alarms/{alarm_id}/state-history/', self.alarms_resource)

        self.app.add_route(
            '/v2.0/alarms/state-history/', self.alarms_resource) 
开发者ID:openstack,项目名称:monasca-api,代码行数:18,代码来源:test_alarms.py

示例10: _test_and_check_logging_communicate_errors

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def _test_and_check_logging_communicate_errors(self, log_errors=None,
                                                   attempts=None):
        mock = self.useFixture(fixtures.MockPatch(
            'subprocess.Popen.communicate',
            side_effect=OSError(errno.EAGAIN, 'fake-test')))

        fixture = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
        kwargs = {}

        if log_errors:
            kwargs.update({"log_errors": log_errors})

        if attempts:
            kwargs.update({"attempts": attempts})

        self.assertRaises(OSError,
                          processutils.execute,
                          '/usr/bin/env',
                          'false',
                          **kwargs)

        self.assertEqual(attempts if attempts else 1, mock.mock.call_count)
        self.assertIn('Got an OSError', fixture.output)
        self.assertIn('errno: %d' % errno.EAGAIN, fixture.output)
        self.assertIn("'/usr/bin/env false'", fixture.output) 
开发者ID:openstack,项目名称:oslo.concurrency,代码行数:27,代码来源:test_processutils.py

示例11: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestAssociations, self).setUp()

        self.mock_get_inv = self.useFixture(fixtures.MockPatch(
            'zun.scheduler.client.report.SchedulerReportClient.'
            '_get_inventory')).mock
        self.inv = {
            'VCPU': {'total': 16},
            'MEMORY_MB': {'total': 1024},
            'DISK_GB': {'total': 10},
        }
        self.mock_get_inv.return_value = {
            'resource_provider_generation': 41,
            'inventories': self.inv,
        }

        self.mock_get_aggs = self.useFixture(fixtures.MockPatch(
            'zun.scheduler.client.report.SchedulerReportClient.'
            '_get_provider_aggregates')).mock
        self.mock_get_aggs.return_value = report.AggInfo(
            aggregates=set([uuids.agg1]), generation=42)

        self.mock_get_traits = self.useFixture(fixtures.MockPatch(
            'zun.scheduler.client.report.SchedulerReportClient.'
            'get_provider_traits')).mock
        self.mock_get_traits.return_value = report.TraitInfo(
            traits=set(['CUSTOM_GOLD']), generation=43)

        self.mock_get_sharing = self.useFixture(fixtures.MockPatch(
            'zun.scheduler.client.report.SchedulerReportClient.'
            '_get_sharing_providers')).mock 
开发者ID:openstack,项目名称:zun,代码行数:33,代码来源:test_report.py

示例12: _setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def _setUp(self):
        self.client = mock.Mock(k8s_client.K8sClient)
        self.useFixture(fixtures.MockPatch(
            'kuryr_kubernetes.clients.get_kubernetes_client',
            lambda: self.client)) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:7,代码来源:kuryr_fixtures.py

示例13: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(TestRetryHandler, self).setUp()

        self.now = time.time()
        f_time = self.useFixture(fixtures.MockPatch('time.time'))
        f_time.mock.return_value = self.now

        self.k8s = self.useFixture(k_fix.MockK8sClient()).client
        f_k8s = self.useFixture(fixtures.MockPatch(
            'kuryr_kubernetes.clients.get_kubernetes_client'))
        f_k8s.mock.return_value = self.k8s 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:13,代码来源:test_retry.py

示例14: setUp

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def setUp(self):
        super(KeystoneContextMiddlewareTest, self).setUp()
        self.app = middleware.KeystoneContextMiddleware({})

        self.request = FakeRequest()

        # Replace the DesignateContext class..
        self.ctxt = mock.Mock()
        self.useFixture(fixtures.MockPatch(
            'designate.context.DesignateContext',
            return_value=self.ctxt
        )) 
开发者ID:openstack,项目名称:designate,代码行数:14,代码来源:test_middleware.py

示例15: FIXME_test_increment_zone_serial

# 需要导入模块: import fixtures [as 别名]
# 或者: from fixtures import MockPatch [as 别名]
def FIXME_test_increment_zone_serial(self, utils_inc_ser):
        fixtures.MockPatch('designate.central.service.utils.increment_serial')
        zone = RoObject(serial=1)
        self.service._increment_zone_serial(self.context, zone) 
开发者ID:openstack,项目名称:designate,代码行数:6,代码来源:test_basic.py


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