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

Python stubs._fake_instance函数代码示例

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

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



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

示例1: test_container_pause_fail

 def test_container_pause_fail(self, tag, side_effect, expected):
     """
     container_pause pauses a contianer on a LXD host. Verify
     that an exception.NovaException is raised when there
     is an APIError.
     """
     instance = stubs._fake_instance()
     instance = stubs._fake_instance()
     self.ml.container_suspend.side_effect = side_effect
     self.assertRaises(expected,
                       self.session.container_pause,
                       instance.name, instance)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:12,代码来源:test_session.py


示例2: test_container_destroy

 def test_container_destroy(self, tag, container_defined, side_effect):
     """
     container_destroy delete a container from the LXD Host. Check
     that the approiate pylxd calls are made.
     """
     instance = stubs._fake_instance()
     if container_defined:
         self.ml.container_defined.return_value = container_defined
         self.ml.container_stop.return_value = side_effect
         self.ml.container_destroy.return_value = side_effect
         self.assertEqual(None,
                          self.session.container_destroy(instance.name,
                                                         instance))
         calls = [mock.call.container_defined(instance.name),
                  mock.call.container_defined(instance.name),
                  mock.call.container_stop(instance.name, -1),
                  mock.call.wait_container_operation(
             '/1.0/operation/1234', 200, -1),
             mock.call.container_destroy(instance.name),
             mock.call.wait_container_operation(
             '/1.0/operation/1234', 200, -1)]
         self.assertEqual(calls, self.ml.method_calls)
     if not container_defined:
         self.ml.container_defined.return_value = container_defined
         self.assertEqual(None,
                          self.session.container_destroy(instance.name,
                                                         instance))
         calls = [mock.call.container_defined(instance.name)]
         self.assertEqual(calls, self.ml.method_calls)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:29,代码来源:test_session.py


示例3: test_confirm_migration

    def test_confirm_migration(self):
        migration = mock.Mock()
        instance = stubs._fake_instance()
        network_info = mock.Mock()

        with test.nested(
            mock.patch.object(session.LXDAPISession, 'container_defined'),
            mock.patch.object(session.LXDAPISession, 'profile_delete'),
            mock.patch.object(session.LXDAPISession, 'container_destroy'),
            mock.patch.object(operations.LXDContainerOperations,
                              'unplug_vifs'),
        ) as (
                mock_container_defined,
                mock_profile_delete,
                mock_container_destroy,
                mock_unplug_vifs):
            self.assertEqual(None,
                             self.migrate.confirm_migration(migration,
                                                            instance,
                                                            network_info))
            mock_container_defined.assert_called_once_with(instance.name,
                                                           instance)
            mock_profile_delete.assert_called_once_with(instance)
            mock_unplug_vifs.assert_called_once_with(instance,
                                                     network_info)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:25,代码来源:test_migrate.py


示例4: test_profile_delete

 def test_profile_delete(self):
     instance = stubs._fake_instance()
     self.ml.profile_defined.return_value = True
     self.ml.profile_delete.return_value = \
         (200, fake_api.fake_standard_return())
     self.assertEqual(None,
                      self.session.profile_delete(instance))
开发者ID:dstelter,项目名称:nova-lxd,代码行数:7,代码来源:test_session.py


示例5: test_get_config_bridge

    def test_get_config_bridge(self):
        instance = stubs._fake_instance()
        vif_data = copy.deepcopy(self.vif_data)

        vif_type = self.vif_driver.get_config(instance, vif_data)
        self.assertEqual(vif_type, {'bridge': 'qbr0123456789a',
                                    'mac_address': '00:11:22:33:44:55'})
开发者ID:dstelter,项目名称:nova-lxd,代码行数:7,代码来源:test_vif_api.py


示例6: test_container_wait

 def test_container_wait(self):
     instance = stubs._fake_instance()
     operation_id = mock.Mock()
     self.ml.wait_container_operation.return_value = True
     self.assertIsNone(self.session.operation_wait(operation_id, instance))
     self.ml.wait_container_operation.assert_called_with(operation_id,
                                                         200, -1)
开发者ID:openstack,项目名称:nova-lxd,代码行数:7,代码来源:test_session.py


示例7: test_migrate_disk_power_off_resize

    def test_migrate_disk_power_off_resize(self):
        self.flags(my_ip='fakeip')
        instance = stubs._fake_instance()
        network_info = mock.Mock()
        flavor = mock.Mock()
        context = mock.Mock()
        dest = 'fakeip'

        with test.nested(
            mock.patch.object(session.LXDAPISession, 'container_defined'),
            mock.patch.object(config.LXDContainerConfig, 'create_profile'),
            mock.patch.object(session.LXDAPISession, 'profile_update')
        ) as (
            mock_container_defined,
            mock_create_profile,
            mock_profile_update
        ):
            self.assertEqual('',
                             self.migrate.migrate_disk_and_power_off(
                                 context, instance, dest, flavor,
                                 network_info))
            mock_container_defined.assert_called_once_with(instance.name,
                                                           instance)
            mock_create_profile.assert_called_once_with(instance,
                                                        network_info)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:25,代码来源:test_migrate.py


示例8: test_container_snapshot_fail

 def test_container_snapshot_fail(self, tag, side_effect, expected):
     snapshot = mock.Mock()
     instance = stubs._fake_instance()
     self.ml.container_snapshot_create.side_effect = side_effect
     self.assertRaises(expected,
                       self.session.container_snapshot,
                       instance.name, snapshot)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:7,代码来源:test_session.py


示例9: test_image_defined

 def test_image_defined(self):
     """Test the image is defined in the LXD hypervisor."""
     instance = stubs._fake_instance()
     self.ml.alias_defined.return_value = True
     self.assertTrue(self.session.image_defined(instance))
     calls = [mock.call.alias_defined(instance.image_ref)]
     self.assertEqual(calls, self.ml.method_calls)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:7,代码来源:test_session.py


示例10: test_create_container

 def test_create_container(self, tag, key, expected):
     """Tests the create_container methond on LXDContainerConfig.
        Inspect that the correct dictionary is returned for a given
        instance.
     """
     instance = stubs._fake_instance()
     container_config = self.config.create_container(instance)
     self.assertEqual(container_config[key], expected)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:8,代码来源:test_config.py


示例11: test_alias_create

 def test_alias_create(self):
     """Test the alias is created."""
     instance = stubs._fake_instance()
     alias = mock.Mock()
     self.ml.alias_create.return_value = True
     self.assertTrue(self.session.create_alias(alias, instance))
     calls = [mock.call.alias_create(alias)]
     self.assertEqual(calls, self.ml.method_calls)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:8,代码来源:test_session.py


示例12: test_create_disk_path

 def test_create_disk_path(self):
     instance = stubs._fake_instance()
     config = self.config.configure_disk_path('/fake/src_path',
                                              '/fake/dest_path',
                                              'fake_disk', instance)
     self.assertEqual({'fake_disk': {'path': '/fake/dest_path',
                                     'source': '/fake/src_path',
                                     'type': 'disk',
                                     'optional': 'True'}}, config)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:9,代码来源:test_config.py


示例13: test_get_info

 def test_get_info(self, tag, side_effect, expected):
     instance = stubs._fake_instance()
     with mock.patch.object(session.LXDAPISession,
                            "container_state",
                            ) as state:
         state.return_value = side_effect
         info = self.connection.get_info(instance)
         self.assertEqual(dir(hardware.InstanceInfo(state=expected,
                                                    num_cpu=2)), dir(info))
开发者ID:dstelter,项目名称:nova-lxd,代码行数:9,代码来源:test_driver_api.py


示例14: test_container_suspend

 def test_container_suspend(self):
     instance = stubs._fake_instance()
     context = mock.Mock()
     with test.nested(
         mock.patch.object(session.LXDAPISession, 'container_pause')
     ) as (mock_container_suspend):
         self.assertEqual(None,
                          self.operations.suspend(context, instance))
         self.assertTrue(mock_container_suspend)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:9,代码来源:test_operations.py


示例15: test_container_publish

 def test_container_publish(self, tag, side_effect):
     image = mock.Mock()
     instance = stubs._fake_instance()
     self.ml.image_export.return_value = True
     self.assertTrue(
         self.session.container_publish(image, instance))
     calls = [
         mock.call.container_publish(image)]
     self.assertEqual(calls, self.ml.method_calls)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:9,代码来源:test_session.py


示例16: test_disk_quota_total_iops

 def test_disk_quota_total_iops(self):
     instance = stubs._fake_instance()
     instance.flavor.extra_specs = {
         'quota:disk_total_iops_sec': 10000
     }
     config = self.config.configure_container_root(instance)
     self.assertEqual({'root': {'path': '/',
                                'type': 'disk',
                                'size': '10GB',
                                'limits.max': '10000iops'}}, config)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:10,代码来源:test_config.py


示例17: test_container_snapshot

 def test_container_snapshot(self, tag, side_effect):
     snapshot = mock.Mock()
     instance = stubs._fake_instance()
     self.ml.container_snapshot_create.return_value = side_effect
     self.assertEqual(None,
                      self.session.container_snapshot(snapshot, instance))
     calls = [
         mock.call.container_snapshot_create(instance.name, snapshot),
         mock.call.wait_container_operation('/1.0/operation/1234', 200, -1)]
     self.assertEqual(calls, self.ml.method_calls)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:10,代码来源:test_session.py


示例18: test_container_power_off

 def test_container_power_off(self):
     instance = stubs._fake_instance()
     with test.nested(
             mock.patch.object(self.connection.container_ops,
                               'power_off')
     ) as (
             power_off
     ):
         self.connection.power_off(instance)
         self.assertTrue(power_off)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:10,代码来源:test_driver_api.py


示例19: test_create_network

 def test_create_network(self):
     instance = stubs._fake_instance()
     instance_name = 'fake_instance'
     network_info = fake_network.fake_get_instance_nw_info(self)
     config = self.config.create_network(instance_name, instance,
                                         network_info)
     self.assertEqual({'fake_br1': {'hwaddr': 'DE:AD:BE:EF:00:01',
                                    'nictype': 'bridged',
                                    'parent': 'fake_br1',
                                    'type': 'nic'}}, config)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:10,代码来源:test_config.py


示例20: test_container_reboot_fail

 def test_container_reboot_fail(self, tag, side_effect, expected):
     """
     container_reboot reboots a container on a given LXD host.
     Check that an exception.NovaException is raised when
     there is an LXD API error.
     """
     instance = stubs._fake_instance()
     self.ml.container_reboot.side_effect = side_effect
     self.assertRaises(expected,
                       self.session.container_reboot, instance)
开发者ID:dstelter,项目名称:nova-lxd,代码行数:10,代码来源:test_session.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python stubydoo.double函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_hostname函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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