本文整理汇总了Python中mock.Mock.manager方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.manager方法的具体用法?Python Mock.manager怎么用?Python Mock.manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.Mock
的用法示例。
在下文中一共展示了Mock.manager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_shard
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_add_shard(self,
mock_find_all,
mock_load_any_instance,
mock_check_quotas,
mock_instance_create,
mock_update_db,
mock_task_api_load,
mock_load_by_uuid):
self.cluster.db_info.task_status = ClusterTasks.NONE
(mock_find_all.return_value
.all.return_value) = [DBInstance(InstanceTasks.NONE,
name="TestInstance1",
shard_id="1", id='1',
datastore_version_id='1'),
DBInstance(InstanceTasks.NONE,
name="TestInstance2",
shard_id="1", id='2',
datastore_version_id='1'),
DBInstance(InstanceTasks.NONE,
name="TestInstance3",
shard_id="1", id='3',
datastore_version_id='1')]
mock_datastore_version = Mock()
mock_datastore_version.manager = 'mongodb'
mock_load_by_uuid.return_value = mock_datastore_version
mock_task_api = Mock()
mock_task_api.mongodb_add_shard_cluster.return_value = None
mock_task_api_load.return_value = mock_task_api
self.cluster.add_shard()
mock_update_db.assert_called_with(
task_status=ClusterTasks.ADDING_SHARD)
mock_task_api.mongodb_add_shard_cluster.assert_called_with(
self.cluster.id, 'new-shard-id', 'rs2')
示例2: test_create_clusters
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_create_clusters(self,
mock_get_datastore_version,
mock_id_from_href,
mock_cluster_create):
body = self.cluster
tenant_id = Mock()
context = Mock()
req = Mock()
req.environ = Mock()
req.environ.__getitem__ = Mock(return_value=context)
datastore_version = Mock()
datastore_version.manager = 'vertica'
datastore = Mock()
mock_get_datastore_version.return_value = (datastore,
datastore_version)
instances = [{'volume_size': 1, 'flavor_id': '1234'},
{'volume_size': 1, 'flavor_id': '1234'},
{'volume_size': 1, 'flavor_id': '1234'}]
mock_id_from_href.return_value = '1234'
mock_cluster = Mock()
mock_cluster.instances = []
mock_cluster.instances_without_server = []
mock_cluster.datastore_version.manager = 'vertica'
mock_cluster_create.return_value = mock_cluster
self.controller.create(req, body, tenant_id)
mock_cluster_create.assert_called_with(context, 'products',
datastore, datastore_version,
instances)
示例3: test_create_clusters_disabled
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_create_clusters_disabled(self,
mock_cluster_create,
mock_get_datastore_version):
cfg.CONF.set_override('cluster_support', False, group='redis',
enforce_type=True)
body = self.cluster
tenant_id = Mock()
context = trove_testtools.TroveTestContext(self)
req = Mock()
req.environ = MagicMock()
req.environ.get = Mock(return_value=context)
datastore_version = Mock()
datastore_version.manager = 'redis'
mock_get_datastore_version.return_value = (Mock(), datastore_version)
self.assertRaisesRegexp(exception.TroveError,
"Clusters not supported for",
self.controller.create,
req,
body,
tenant_id)
示例4: test_replica_config_rendering
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_replica_config_rendering(self):
datastore = Mock(spec=DatastoreVersion)
datastore.datastore_name = "MySql"
datastore.name = "mysql-5.6"
datastore.manager = "mysql"
config = template.ReplicaConfigTemplate(datastore, self.flavor_dict, self.server_id)
self.assertTrue(self._find_in_template(config.render(), "relay_log"))
示例5: test_single_instance_config_rendering
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_single_instance_config_rendering(self):
datastore = Mock(spec=DatastoreVersion)
datastore.datastore_name = "MySql"
datastore.name = "mysql-5.6"
datastore.manager = "mysql"
config = template.SingleInstanceConfigTemplate(datastore, self.flavor_dict, self.server_id)
self.validate_template(config.render(), "query_cache_size", self.flavor_dict, self.server_id)
示例6: test_create_clusters
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_create_clusters(self, mock_get_datastore_version, mock_id_from_href, mock_cluster_create):
body = self.cluster
tenant_id = Mock()
context = trove_testtools.TroveTestContext(self)
req = Mock()
req.environ = Mock()
req.environ.__getitem__ = Mock(return_value=context)
datastore_version = Mock()
datastore_version.manager = "mongodb"
datastore = Mock()
mock_get_datastore_version.return_value = (datastore, datastore_version)
instances = [
{
"volume_size": 1,
"volume_type": None,
"flavor_id": "1234",
"availability_zone": "az",
"modules": None,
"region_name": None,
"nics": [{"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}],
}
] * 5
mock_id_from_href.return_value = "1234"
mock_cluster = Mock()
mock_cluster.instances = []
mock_cluster.instances_without_server = []
mock_cluster.datastore_version.manager = "mongodb"
mock_cluster_create.return_value = mock_cluster
self.controller.create(req, body, tenant_id)
mock_cluster_create.assert_called_with(
context, "products", datastore, datastore_version, instances, {}, self.locality
)
示例7: _start_mysql
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def _start_mysql(self):
datastore = Mock(spec=DatastoreVersion)
datastore.datastore_name = 'mysql'
datastore.name = 'mysql-5.6'
datastore.manager = 'mysql'
config = template.SingleInstanceConfigTemplate(
datastore, NEW_FLAVOR.__dict__, self.instance.id)
self.instance.guest.start_db_with_conf_changes(config.render())
示例8: test_renderer_discovers_special_config
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_renderer_discovers_special_config(self):
"""Finds our special config file for the version 'mysql-test'."""
datastore = Mock(spec=DatastoreVersion)
datastore.datastore_name = "mysql"
datastore.name = "mysql-test"
datastore.manager = "mysql"
config = template.SingleInstanceConfigTemplate(datastore, self.flavor_dict, self.server_id)
self.validate_template(config.render(), "hyper", {"ram": 0}, self.server_id)
示例9: test_load
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_load(self, mock_find_by, mock_load_dsv_by_uuid, mock_ds_load):
context = trove_testtools.TroveTestContext(self)
id = Mock()
dsv = Mock()
dsv.manager = 'mongodb'
mock_load_dsv_by_uuid.return_value = dsv
cluster = models.Cluster.load(context, id)
self.assertTrue(isinstance(cluster, MongoDbCluster))
示例10: test_create_clusters
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_create_clusters(self,
mock_get_datastore_version,
mock_id_from_href,
mock_cluster_create):
body = self.cluster
tenant_id = Mock()
context = Mock()
req = Mock()
req.environ = Mock()
req.environ.__getitem__ = Mock(return_value=context)
datastore_version = Mock()
datastore_version.manager = 'redis'
datastore = Mock()
mock_get_datastore_version.return_value = (datastore,
datastore_version)
instances = [
{
"volume_size": None,
'volume_type': None,
"flavor_id": "1234",
"availability_zone": "az",
"nics": [
{"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}
]
},
{
"volume_size": None,
'volume_type': None,
"flavor_id": "1234",
"availability_zone": "az",
"nics": [
{"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}
]
},
{
"volume_size": None,
'volume_type': None,
"flavor_id": "1234",
"availability_zone": "az",
"nics": [
{"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}
]
}
]
mock_id_from_href.return_value = '1234'
mock_cluster = Mock()
mock_cluster.instances = []
mock_cluster.instances_without_server = []
mock_cluster.datastore_version.manager = 'redis'
mock_cluster_create.return_value = mock_cluster
self.controller.create(req, body, tenant_id)
mock_cluster_create.assert_called_with(context, 'products',
datastore, datastore_version,
instances, {})
示例11: test_load
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_load(self, mock_find_by, mock_load_dsv_by_uuid, mock_ds_load):
context = Mock()
id = Mock()
dsv = Mock()
dsv.manager = 'mongodb'
mock_load_dsv_by_uuid.return_value = dsv
cluster = models.Cluster.load(context, id)
self.assertIsInstance(cluster, MongoDbCluster)
示例12: test_replica_source_config_rendering
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_replica_source_config_rendering(self):
datastore = Mock(spec=DatastoreVersion)
datastore.datastore_name = 'MySql'
datastore.name = 'mysql-5.6'
datastore.manager = 'mysql'
config = template.ReplicaSourceConfigTemplate(datastore,
self.flavor_dict,
self.server_id)
self.assertTrue(self._find_in_template(config.render(), "log_bin"))
示例13: test_create_clusters_disabled
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_create_clusters_disabled(self, mock_get_datastore_version, mock_cluster_create):
body = self.cluster
tenant_id = Mock()
context = trove_testtools.TroveTestContext(self)
req = Mock()
req.environ = MagicMock()
req.environ.get = Mock(return_value=context)
datastore_version = Mock()
datastore_version.manager = "mysql"
mock_get_datastore_version.return_value = (Mock(), datastore_version)
self.assertRaises(exception.ClusterDatastoreNotSupported, self.controller.create, req, body, tenant_id)
示例14: test_load
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_load(self, mock_inst_load, mock_find_by,
mock_load_dsv_by_uuid, mock_ds_load):
context = trove_testtools.TroveTestContext(self)
id = Mock()
inst_mock = Mock()
server_group = Mock()
inst_mock.server_group = server_group
mock_inst_load.return_value = [inst_mock]
dsv = Mock()
dsv.manager = 'mongodb'
mock_load_dsv_by_uuid.return_value = dsv
cluster = models.Cluster.load(context, id)
self.assertIsInstance(cluster, MongoDbCluster)
self.assertEqual(server_group, cluster.server_group,
"Unexpected server group")
示例15: test_create_clusters_disabled
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import manager [as 别名]
def test_create_clusters_disabled(self, mock_cluster_create, mock_get_datastore_version):
cfg.CONF.set_override("cluster_support", False, group="pxc", enforce_type=True)
body = self.cluster
tenant_id = Mock()
context = Mock()
req = Mock()
req.environ = MagicMock()
req.environ.get = Mock(return_value=context)
datastore_version = Mock()
datastore_version.manager = "pxc"
mock_get_datastore_version.return_value = (Mock(), datastore_version)
self.assertRaises(exception.TroveError, self.controller.create, req, body, tenant_id)