本文整理汇总了Python中tempest.lib.common.utils.data_utils.arbitrary_string函数的典型用法代码示例。如果您正苦于以下问题:Python arbitrary_string函数的具体用法?Python arbitrary_string怎么用?Python arbitrary_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了arbitrary_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_arbitrary_string
def test_arbitrary_string(self):
actual = data_utils.arbitrary_string()
self.assertEqual(actual, "test")
actual = data_utils.arbitrary_string(size=30, base_text="abc")
self.assertEqual(actual, "abc" * int(30 / len("abc")))
actual = data_utils.arbitrary_string(size=5, base_text="deadbeaf")
self.assertEqual(actual, "deadb")
示例2: test_create_subscriptions_with_invalid_body
def test_create_subscriptions_with_invalid_body(self):
# Missing subscriber parameter in body
message_ttl = data_utils.\
rand_int_id(start=60, end=CONF.messaging.max_message_ttl)
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
value = data_utils.arbitrary_string(size=20,
base_text='MessagingValue')
option_body = {key: value}
rbody = {'options': option_body, 'ttl': message_ttl}
self.assertRaises(lib_exc.BadRequest,
self.create_subscription, self.queue_name, rbody)
示例3: generate_message_body
def generate_message_body(cls, repeat=1):
"""Wrapper utility that sets the metadata of a queue."""
message_ttl = data_utils.\
rand_int_id(start=60, end=CONF.messaging.max_message_ttl)
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
value = data_utils.arbitrary_string(size=20,
base_text='MessagingValue')
message_body = {key: value}
rbody = ([{'body': message_body, 'ttl': message_ttl}] * repeat)
return rbody
示例4: test_create_subscriptions_with_non_integer_value_for_ttl
def test_create_subscriptions_with_non_integer_value_for_ttl(self):
# The subscriber type of subscription must be supported in the list
# ['http', 'https', 'mailto']
message_ttl = "123"
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
value = data_utils.arbitrary_string(size=20,
base_text='MessagingValue')
option_body = {key: value}
subscriber = 'http://fake:8080'
rbody = {'options': option_body, 'ttl': message_ttl,
'subscriber': subscriber}
self.assertRaises(lib_exc.BadRequest,
self.create_subscription, self.queue_name, rbody)
示例5: generate_subscription_body
def generate_subscription_body(cls):
message_ttl = data_utils.\
rand_int_id(start=60, end=CONF.messaging.max_message_ttl)
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
value = data_utils.arbitrary_string(size=20,
base_text='MessagingValue')
option_body = {key: value}
subscribers = ['http://fake:8080', 'https://fake:8080',
'mailto:[email protected]']
rbody = [{'options': option_body, 'ttl': message_ttl,
'subscriber': subscriber} for subscriber in subscribers]
return rbody
示例6: test_post_messages_without_TTL
def test_post_messages_without_TTL(self):
# TTL for a message may not exceed 1209600 seconds, and
# must be at least 60 seconds long.
queue_name = self.queues[data_utils.rand_int_id(0,
len(self.queues) - 1)]
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
value = data_utils.arbitrary_string(size=20,
base_text='MessagingValue')
message_body = {key: value}
rbody = ([{'body': message_body}] * 1)
self.assertRaises(lib_exc.BadRequest,
self.client.post_messages, queue_name, rbody)
示例7: test_create_subscriptions_with_invalid_subscriber
def test_create_subscriptions_with_invalid_subscriber(self):
# The subscriber type of subscription must be supported in the list
# ['http', 'https', 'mailto']
message_ttl = data_utils.\
rand_int_id(start=60, end=CONF.messaging.max_message_ttl)
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
value = data_utils.arbitrary_string(size=20,
base_text='MessagingValue')
option_body = {key: value}
subscriber = 'fake'
rbody = {'options': option_body, 'ttl': message_ttl,
'subscriber': subscriber}
self.assertRaises(lib_exc.BadRequest,
self.create_subscription, self.queue_name, rbody)
示例8: test_post_messages_with_invalid_body_size
def test_post_messages_with_invalid_body_size(self):
# Maximum number of queue message per page
# while posting messages is 20
queue_name = self.queues[data_utils.rand_int_id(0,
len(self.queues) - 1)]
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
value = data_utils.arbitrary_string(size=20,
base_text='MessagingValue')
message_ttl = data_utils.\
rand_int_id(start=60, end=CONF.messaging.max_message_ttl)
message_body = {key: value}
rbody = ([{'body': message_body, 'ttl': message_ttl}] * 21)
self.assertRaises(lib_exc.BadRequest,
self.client.post_messages, queue_name, rbody)
示例9: test_upload_valid_object
def test_upload_valid_object(self):
object_name = data_utils.rand_name(name="TestObject")
data = data_utils.arbitrary_string()
resp, _ = self.object_client.create_object(self.container_name,
object_name, data)
self.assertHeaders(resp, 'Object', 'PUT')
示例10: verify_metadata
def verify_metadata(self):
if self.run_ssh and CONF.compute_feature_enabled.metadata_service:
# Verify metadata service
md_url = 'http://169.254.169.254/latest/meta-data/public-ipv4'
def exec_cmd_and_verify_output():
cmd = 'curl ' + md_url
result = self.ssh_client.exec_command(cmd)
if result:
msg = ('Failed while verifying metadata on server. Result '
'of command "%s" is NOT "%s".' % (cmd, self.fip))
self.assertEqual(self.fip, result, msg)
return 'Verification is successful!'
if not test_utils.call_until_true(exec_cmd_and_verify_output,
CONF.compute.build_timeout,
CONF.compute.build_interval):
raise exceptions.TimeoutException('Timed out while waiting to '
'verify metadata on server. '
'%s is empty.' % md_url)
# Also, test a POST
md_url = 'http://169.254.169.254/openstack/2013-10-17/password'
data = data_utils.arbitrary_string(100)
cmd = 'curl -X POST -d ' + data + ' ' + md_url
self.ssh_client.exec_command(cmd)
result = self.servers_client.show_password(self.instance['id'])
self.assertEqual(data, result['password'])
示例11: test_create_node_resource_class_long
def test_create_node_resource_class_long(self):
"""Create new node with specified longest name of resource class."""
res_class_long_name = data_utils.arbitrary_string(80)
_, body = self.create_node(
self.chassis['uuid'],
resource_class=res_class_long_name)
self.assertEqual(res_class_long_name, body['resource_class'])
示例12: upload_object_to_container
def upload_object_to_container(self, container_name):
obj_name = data_utils.rand_name('swift-scenario-object')
obj_data = data_utils.arbitrary_string()
self.object_client.create_object(container_name, obj_name, obj_data)
self.addCleanup(self.object_client.delete_object,
container_name,
obj_name)
return obj_name
示例13: test_post_messages_with_TTL_less_than_60
def test_post_messages_with_TTL_less_than_60(self):
# TTL for a message may not exceed 1209600 seconds,
# and must be at least 60 seconds long.
queue_name = self.queues[data_utils.rand_int_id(0,
len(self.queues) - 1)]
message_ttl = data_utils.\
rand_int_id(start=0, end=60)
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
value = data_utils.arbitrary_string(size=20,
base_text='MessagingValue')
message_body = {key: value}
rbody = ([{'body': message_body, 'ttl': message_ttl}] * 1)
self.assertRaises(lib_exc.BadRequest,
self.client.post_messages, queue_name, rbody)
示例14: test_create_a_subscription_without_a_token
def test_create_a_subscription_without_a_token(self):
# X-Auth-Token is not provided
message_ttl = data_utils.\
rand_int_id(start=60, end=CONF.messaging.max_message_ttl)
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
value = data_utils.arbitrary_string(size=20,
base_text='MessagingValue')
option_body = {key: value}
subscriber = 'http://fake:8080'
rbody = {'options': option_body, 'ttl': message_ttl,
'subscriber': subscriber}
self.client.auth_provider.set_alt_auth_data(
request_part='headers',
auth_data=None
)
self.assertRaises(lib_exc.Unauthorized,
self.create_subscription, self.queue_name, rbody)
示例15: test_list_nodes_by_resource_class_old_api
def test_list_nodes_by_resource_class_old_api(self):
"""Try to list nodes with resource class using older api version."""
resource_class = data_utils.arbitrary_string()
self.assertRaises(
lib_exc.UnexpectedResponseCode,
self.client.list_nodes, resource_class=resource_class)
self.assertRaises(
lib_exc.UnexpectedResponseCode,
self.client.list_nodes_detail, resource_class=resource_class)