本文整理汇总了Python中trove.tests.util.check.AttrCheck类的典型用法代码示例。如果您正苦于以下问题:Python AttrCheck类的具体用法?Python AttrCheck怎么用?Python AttrCheck使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AttrCheck类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_flavor_get_attrs
def test_flavor_get_attrs(self):
allowed_attrs = ["id", "name", "ram", "links", "local_storage", "str_id"]
flavor = self.rd_client.flavors.get(1)
attrcheck = AttrCheck()
flavor_dict = flavor._info
attrcheck.contains_allowed_attrs(flavor_dict, allowed_attrs, msg="Flavor Get 1")
attrcheck.links(flavor_dict["links"])
开发者ID:cretta,项目名称:trove,代码行数:7,代码来源:flavors.py
示例2: test_expected_get_configuration_parameter
def test_expected_get_configuration_parameter(self):
# tests get on a single parameter to verify it has expected attributes
param_name = 'key_buffer_size'
allowed_config_params = ['name', 'restart_required',
'max', 'min', 'type',
'deleted', 'deleted_at',
'datastore_version_id']
param = instance_info.dbaas.configuration_parameters.get_parameter(
instance_info.dbaas_datastore,
instance_info.dbaas_datastore_version,
param_name)
resp, body = instance_info.dbaas.client.last_response
print("params: %s" % param)
print("resp: %s" % resp)
print("body: %s" % body)
attrcheck = AttrCheck()
config_parameter_dict = json.loads(body)
print("config_parameter_dict: %s" % config_parameter_dict)
attrcheck.contains_allowed_attrs(
config_parameter_dict,
allowed_config_params,
msg="Get Configuration parameter")
assert_equal(param_name, config_parameter_dict['name'])
with TypeCheck('ConfigurationParameter', param) as parameter:
parameter.has_field('name', six.string_types)
parameter.has_field('restart_required', bool)
parameter.has_field('max', six.integer_types)
parameter.has_field('min', six.integer_types)
parameter.has_field('type', six.string_types)
parameter.has_field('datastore_version_id', six.text_type)
开发者ID:tangguochang,项目名称:trove,代码行数:30,代码来源:configurations.py
示例3: _test_configuration_is_applied_to_instance
def _test_configuration_is_applied_to_instance(instance, configuration_id):
if CONFIG.fake_mode:
raise SkipTest("configuration from sql does not work in fake mode")
instance_test = instance_info.dbaas.instances.get(instance.id)
assert_equal(configuration_id, instance_test.configuration['id'])
if configuration_id:
testconfig_info = instance_info.dbaas.configurations.get(
configuration_id)
else:
testconfig_info = instance_info.dbaas.instance.configuration(
instance.id)
testconfig_info['configuration']
conf_instances = instance_info.dbaas.configurations.instances(
configuration_id)
config_instance_ids = [inst.id for inst in conf_instances]
assert_true(instance_test.id in config_instance_ids)
cfg_names = testconfig_info.values.keys()
host = _get_address(instance.id)
for user in instance.users:
username = user['name']
password = user['password']
concat_variables = "','".join(cfg_names)
query = ("show variables where Variable_name "
"in ('%s');" % concat_variables)
actual_values = _execute_query(host, username, password, query)
print("actual_values %s" % actual_values)
print("testconfig_info.values %s" % testconfig_info.values)
assert_true(len(actual_values) == len(cfg_names))
# check the configs exist
attrcheck = AttrCheck()
expected_attrs = [actual_key for actual_key, actual_value in actual_values]
attrcheck.attrs_exist(testconfig_info.values, expected_attrs,
msg="Configurations parameters")
def _get_parameter_type(name):
instance_info.dbaas.configuration_parameters.get_parameter(
instance_info.dbaas_datastore,
instance_info.dbaas_datastore_version,
name)
resp, body = instance_info.dbaas.client.last_response
print(resp)
print(body)
return json.loads(body)['type']
# check the config values are correct
for key, value in actual_values:
key_type = _get_parameter_type(key)
# mysql returns 'ON' and 'OFF' for True and False respectively
if value == 'ON':
converted_key_value = (str(key), 1)
elif value == 'OFF':
converted_key_value = (str(key), 0)
else:
if key_type == 'integer':
value = int(value)
converted_key_value = (str(key), value)
print("converted_key_value: %s" % str(converted_key_value))
assert_true(converted_key_value in testconfig_info.values.items())
开发者ID:igor-feoktistov,项目名称:trove,代码行数:60,代码来源:configurations.py
示例4: test_flavor_get_attrs
def test_flavor_get_attrs(self):
expected_attrs = ['id', 'name', 'ram', 'links', 'local_storage']
flavor = self.rd_client.flavors.get(1)
attrcheck = AttrCheck()
flavor_dict = flavor._info
attrcheck.attrs_exist(flavor_dict, expected_attrs,
msg="Flavor Get 1")
attrcheck.links(flavor_dict['links'])
开发者ID:citrix-openstack-build,项目名称:trove,代码行数:8,代码来源:flavors.py
示例5: test_flavor_list_attrs
def test_flavor_list_attrs(self):
allowed_attrs = ["id", "name", "ram", "links", "local_storage", "str_id"]
flavors = self.rd_client.flavors.list()
attrcheck = AttrCheck()
for flavor in flavors:
flavor_dict = flavor._info
attrcheck.contains_allowed_attrs(flavor_dict, allowed_attrs, msg="Flavors list")
attrcheck.links(flavor_dict["links"])
开发者ID:cretta,项目名称:trove,代码行数:8,代码来源:flavors.py
示例6: test_flavor_list_attrs
def test_flavor_list_attrs(self):
expected_attrs = ['id', 'name', 'ram', 'links', 'local_storage']
flavors = self.rd_client.flavors.list()
attrcheck = AttrCheck()
for flavor in flavors:
flavor_dict = flavor._info
attrcheck.attrs_exist(flavor_dict, expected_attrs,
msg="Flavors list")
attrcheck.links(flavor_dict['links'])
开发者ID:citrix-openstack-build,项目名称:trove,代码行数:9,代码来源:flavors.py
示例7: test_flavor_get_attrs
def test_flavor_get_attrs(self):
allowed_attrs = ['id', 'name', 'ram', 'links', 'local_storage']
flavor = self.rd_client.flavors.get(1)
attrcheck = AttrCheck()
flavor_dict = flavor._info
attrcheck.contains_allowed_attrs(
flavor_dict, allowed_attrs,
msg="Flavor Get 1")
attrcheck.links(flavor_dict['links'])
开发者ID:SlickNik,项目名称:trove,代码行数:9,代码来源:flavors.py
示例8: test_flavor_list_attrs
def test_flavor_list_attrs(self):
allowed_attrs = ['id', 'name', 'ram', 'vcpus', 'links',
'local_storage', 'str_id']
flavors = self.rd_client.flavors.list()
attrcheck = AttrCheck()
for flavor in flavors:
flavor_dict = flavor._info
attrcheck.contains_allowed_attrs(
flavor_dict, allowed_attrs,
msg="Flavors list")
attrcheck.links(flavor_dict['links'])
开发者ID:Hopebaytech,项目名称:trove,代码行数:11,代码来源:flavors.py
示例9: test_expected_get_configuration_parameter
def test_expected_get_configuration_parameter(self):
# tests get on a single parameter to verify it has expected attributes
param = 'key_buffer_size'
expected_config_params = ['name', 'restart_required', 'max',
'min', 'type']
instance_info.dbaas.configuration_parameters.get_parameter(
instance_info.dbaas_datastore,
instance_info.dbaas_datastore_version,
param)
resp, body = instance_info.dbaas.client.last_response
print(resp)
print(body)
attrcheck = AttrCheck()
config_parameter_dict = json.loads(body)
print(config_parameter_dict)
attrcheck.attrs_exist(config_parameter_dict, expected_config_params,
msg="Get Configuration parameter")
assert_equal(param, config_parameter_dict['name'])
开发者ID:igor-feoktistov,项目名称:trove,代码行数:18,代码来源:configurations.py
示例10: test_expected_configurations_parameters
def test_expected_configurations_parameters(self):
"""test get expected configurations parameters"""
expected_attrs = ["configuration-parameters"]
instance_info.dbaas.configuration_parameters.parameters(
instance_info.dbaas_datastore,
instance_info.dbaas_datastore_version)
resp, body = instance_info.dbaas.client.last_response
attrcheck = AttrCheck()
config_parameters_dict = json.loads(body)
attrcheck.attrs_exist(config_parameters_dict, expected_attrs,
msg="Configurations parameters")
# sanity check that a few options are in the list
config_params_list = config_parameters_dict['configuration-parameters']
config_param_keys = []
for param in config_params_list:
config_param_keys.append(param['name'])
expected_config_params = ['key_buffer_size', 'connect_timeout']
# check for duplicate configuration parameters
msg = "check for duplicate configuration parameters"
assert_equal(len(config_param_keys), len(set(config_param_keys)), msg)
for expected_config_item in expected_config_params:
assert_true(expected_config_item in config_param_keys)
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:22,代码来源:configurations.py
示例11: test_expected_configurations_parameters
def test_expected_configurations_parameters(self):
"""Test get expected configurations parameters."""
expected_attrs = ["configuration-parameters"]
instance_info.dbaas.configuration_parameters.parameters(
instance_info.dbaas_datastore, instance_info.dbaas_datastore_version
)
resp, body = instance_info.dbaas.client.last_response
attrcheck = AttrCheck()
config_parameters_dict = json.loads(body)
attrcheck.attrs_exist(config_parameters_dict, expected_attrs, msg="Configurations parameters")
# sanity check that a few options are in the list
config_params_list = config_parameters_dict["configuration-parameters"]
config_param_keys = []
for param in config_params_list:
config_param_keys.append(param["name"])
expected_configs = self.expected_default_datastore_configs()
expected_config_params = expected_configs.get("parameters_list")
# check for duplicate configuration parameters
msg = "check for duplicate configuration parameters"
assert_equal(len(config_param_keys), len(set(config_param_keys)), msg)
for expected_config_item in expected_config_params:
assert_true(expected_config_item in config_param_keys)
开发者ID:rumale,项目名称:trove,代码行数:22,代码来源:configurations.py
注:本文中的trove.tests.util.check.AttrCheck类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论