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

Python data_utils.arbitrary_string函数代码示例

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

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



在下文中一共展示了arbitrary_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
开发者ID:dwalleck,项目名称:tempest,代码行数:7,代码来源:test_data_utils.py


示例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)
开发者ID:ollie314,项目名称:zaqar,代码行数:11,代码来源:test_subscriptions_negative.py


示例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
开发者ID:ollie314,项目名称:zaqar,代码行数:12,代码来源:base.py


示例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)
开发者ID:ollie314,项目名称:zaqar,代码行数:13,代码来源:test_subscriptions_negative.py


示例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
开发者ID:ollie314,项目名称:zaqar,代码行数:13,代码来源:base.py


示例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)
开发者ID:AvnishPal,项目名称:zaqar,代码行数:14,代码来源:test_messages_negative.py


示例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)
开发者ID:ollie314,项目名称:zaqar,代码行数:14,代码来源:test_subscriptions_negative.py


示例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)
开发者ID:AvnishPal,项目名称:zaqar,代码行数:15,代码来源:test_messages_negative.py


示例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')
开发者ID:vedujoshi,项目名称:tempest,代码行数:7,代码来源:test_account_quotas.py


示例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'])
开发者ID:vedujoshi,项目名称:tempest,代码行数:28,代码来源:test_server_basic_ops.py


示例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'])
开发者ID:Tehsmash,项目名称:ironic,代码行数:7,代码来源:test_nodes.py


示例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
开发者ID:cloudbase,项目名称:ceilometer,代码行数:8,代码来源:test_object_storage_telemetry_middleware.py


示例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)
开发者ID:AvnishPal,项目名称:zaqar,代码行数:17,代码来源:test_messages_negative.py


示例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)
开发者ID:ollie314,项目名称:zaqar,代码行数:18,代码来源:test_subscriptions_negative.py


示例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)
开发者ID:Tehsmash,项目名称:ironic,代码行数:9,代码来源:test_nodes.py


示例16: _create_object

    def _create_object(self, container_name, object_name=None):
        # setup object
        if object_name is None:
            object_name = data_utils.rand_name(name='TestObject')
        data = data_utils.arbitrary_string()
        self.object_client.create_object(container_name,
                                         object_name,
                                         data)

        return object_name
开发者ID:Hybrid-Cloud,项目名称:hybrid-tempest,代码行数:10,代码来源:test_container_services.py


示例17: test_create_container_name_exceeds_max_length

 def test_create_container_name_exceeds_max_length(self):
     # Attempts to create a container name that is longer than max
     max_length = self.constraints['max_container_name_length']
     # create a container with long name
     container_name = data_utils.arbitrary_string(size=max_length + 1)
     ex = self.assertRaises(exceptions.BadRequest,
                            self.container_client.create_container,
                            container_name)
     self.assertIn('Container name length of ' + str(max_length + 1) +
                   ' longer than ' + str(max_length), str(ex))
开发者ID:sebrandon1,项目名称:tempest,代码行数:10,代码来源:test_container_services_negative.py


示例18: test_create_container_metadata_value_exceeds_max_length

 def test_create_container_metadata_value_exceeds_max_length(self):
     # Attempts to create container with metadata value
     # that is longer than max.
     max_length = self.constraints['max_meta_value_length']
     container_name = data_utils.rand_name(name='TestContainer')
     metadata_value = data_utils.arbitrary_string(size=max_length + 1)
     metadata = {'animal': metadata_value}
     ex = self.assertRaises(exceptions.BadRequest,
                            self.container_client.create_container,
                            container_name, metadata=metadata)
     self.assertIn('Metadata value longer than ' + str(max_length), str(ex))
开发者ID:sebrandon1,项目名称:tempest,代码行数:11,代码来源:test_container_services_negative.py


示例19: _upload_segments

    def _upload_segments(self):
        # create object
        object_name = data_utils.rand_name(name='LObject')
        data = data_utils.arbitrary_string()
        segments = 10
        data_segments = [data + str(i) for i in range(segments)]
        # uploading segments
        for i in range(segments):
            self.object_client.create_object_segments(
                self.container_name, object_name, i, data_segments[i])

        return object_name, data_segments
开发者ID:vedujoshi,项目名称:tempest,代码行数:12,代码来源:test_object_services.py


示例20: create_object

    def create_object(cls, container_name, object_name=None,
                      data=None, metadata=None):
        # wrapper that returns a test object
        if object_name is None:
            object_name = data_utils.rand_name(name='TestObject')
        if data is None:
            data = data_utils.arbitrary_string()
        cls.object_client.create_object(container_name,
                                        object_name,
                                        data,
                                        metadata=metadata)

        return object_name, data
开发者ID:Tesora,项目名称:tesora-tempest,代码行数:13,代码来源:base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python data_utils.rand_int_id函数代码示例发布时间:2022-05-27
下一篇:
Python auth.get_credentials函数代码示例发布时间: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