当前位置: 首页>>代码示例>>Python>>正文


Python data_utils.arbitrary_string函数代码示例

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


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

示例1: test_copy_object_2d_way

    def test_copy_object_2d_way(self):
        # create source object
        src_object_name = data_utils.rand_name(name='SrcObject')
        src_data = data_utils.arbitrary_string(size=len(src_object_name) * 2,
                                               base_text=src_object_name)
        resp, _ = self.object_client.create_object(self.container_name,
                                                   src_object_name, src_data)
        # create destination object
        dst_object_name = data_utils.rand_name(name='DstObject')
        dst_data = data_utils.arbitrary_string(size=len(dst_object_name) * 3,
                                               base_text=dst_object_name)
        resp, _ = self.object_client.create_object(self.container_name,
                                                   dst_object_name, dst_data)
        # copy source object to destination
        resp, _ = self.object_client.copy_object_2d_way(self.container_name,
                                                        src_object_name,
                                                        dst_object_name)
        self.assertHeaders(resp, 'Object', 'COPY')
        #Bug 1417469
        #self.assertEqual(
        #    resp['x-copied-from'],
        #    self.container_name + "/" + src_object_name)

        # check data
        self._check_copied_obj(dst_object_name, src_data)
开发者ID:jaspreetw,项目名称:tempest,代码行数:25,代码来源:test_object_services.py

示例2: 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:overcastcloud,项目名称:tempest-lib,代码行数:7,代码来源:test_data_utils.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:gongwayne,项目名称:Openstack,代码行数:12,代码来源:base.py

示例4: 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:gongwayne,项目名称:Openstack,代码行数:13,代码来源:base.py

示例5: test_put_object_using_temp_url

    def test_put_object_using_temp_url(self):
        new_data = data_utils.arbitrary_string(
            size=len(self.object_name),
            base_text=data_utils.rand_name(name="random"))

        expires = self._get_expiry_date()
        url = self._get_temp_url(self.container_name,
                                 self.object_name, "PUT",
                                 expires, self.key)

        # trying to put random data in the object using temp url
        resp, body = self.object_client.put(url, new_data, None)
        self.assertHeaders(resp, 'Object', 'PUT')

        # Testing a HEAD on this Temp URL
        resp, body = self.object_client.head(url)
        self.assertHeaders(resp, 'Object', 'HEAD')

        # Validate that the content of the object has been modified
        url = self._get_temp_url(self.container_name,
                                 self.object_name, "GET",
                                 expires, self.key)

        _, body = self.object_client.get(url)
        self.assertEqual(body, new_data)
开发者ID:NeetaP,项目名称:tempest,代码行数:25,代码来源:test_object_temp_url.py

示例6: 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:NeetaP,项目名称:tempest,代码行数:7,代码来源:test_account_quotas.py

示例7: test_update_object_metadata_with_create_and_remove_metadata

    def test_update_object_metadata_with_create_and_remove_metadata(self):
        # creation and deletion of metadata with one request
        object_name = data_utils.rand_name(name='TestObject')
        data = data_utils.arbitrary_string()
        create_metadata = {'X-Object-Meta-test-meta1': 'Meta1'}
        self.object_client.create_object(self.container_name,
                                         object_name,
                                         data,
                                         metadata=create_metadata)

        update_metadata = {'X-Object-Meta-test-meta2': 'Meta2',
                           'X-Remove-Object-Meta-test-meta1': 'Meta1'}
        resp, _ = self.object_client.update_object_metadata(
            self.container_name,
            object_name,
            update_metadata,
            metadata_prefix='')
        self.assertHeaders(resp, 'Object', 'POST')

        resp, _ = self.object_client.list_object_metadata(
            self.container_name,
            object_name)
        self.assertNotIn('x-object-meta-test-meta1', resp)
        self.assertIn('x-object-meta-test-meta2', resp)
        self.assertEqual(resp['x-object-meta-test-meta2'], 'Meta2')
开发者ID:coreycb,项目名称:tempest,代码行数:25,代码来源:test_object_services.py

示例8: _create_manifest

    def _create_manifest(self):
        # Create a manifest file for SLO uploading
        object_name = data_utils.rand_name(name='TestObject')
        object_name_base_1 = object_name + '_01'
        object_name_base_2 = object_name + '_02'
        data_size = MIN_SEGMENT_SIZE
        self.content = data_utils.arbitrary_string(data_size)
        self._create_object(self.container_name,
                            object_name_base_1,
                            self.content)
        self._create_object(self.container_name,
                            object_name_base_2,
                            self.content)

        path_object_1 = '/%s/%s' % (self.container_name,
                                    object_name_base_1)
        path_object_2 = '/%s/%s' % (self.container_name,
                                    object_name_base_2)
        data_manifest = [{'path': path_object_1,
                          'etag': hashlib.md5(self.content).hexdigest(),
                          'size_bytes': data_size},
                         {'path': path_object_2,
                          'etag': hashlib.md5(self.content).hexdigest(),
                          'size_bytes': data_size}]

        return json.dumps(data_manifest)
开发者ID:Dynavisor,项目名称:tempest,代码行数:26,代码来源:test_object_slo.py

示例9: test_create_object_with_x_fresh_metadata

    def test_create_object_with_x_fresh_metadata(self):
        # create object with x_fresh_metadata
        object_name_base = data_utils.rand_name(name='TestObject')
        data = data_utils.arbitrary_string()
        metadata_1 = {'X-Object-Meta-test-meta': 'Meta'}
        self.object_client.create_object(self.container_name,
                                         object_name_base,
                                         data,
                                         metadata=metadata_1)
        object_name = data_utils.rand_name(name='TestObject')
        metadata_2 = {'X-Copy-From': '%s/%s' % (self.container_name,
                                                object_name_base),
                      'X-Fresh-Metadata': 'true'}
        resp, _ = self.object_client.create_object(
            self.container_name,
            object_name,
            '',
            metadata=metadata_2)
        self.assertHeaders(resp, 'Object', 'PUT')

        resp, body = self.object_client.get_object(self.container_name,
                                                   object_name)
        #Bug = 1417489
        #self.assertNotIn('x-object-meta-test-meta', resp)
        self.assertEqual(data, body)
开发者ID:jaspreetw,项目名称:tempest,代码行数:25,代码来源:test_object_services.py

示例10: _create_object

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

        return object_name, data
开发者ID:coreycb,项目名称:tempest,代码行数:8,代码来源:test_object_services.py

示例11: test_create_object

    def test_create_object(self):
        # create object
        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)
        # create another object
        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')

        # check uploaded content
        _, body = self.object_client.get_object(self.container_name,
                                                object_name)
        self.assertEqual(data, body)
开发者ID:coreycb,项目名称:tempest,代码行数:17,代码来源:test_object_services.py

示例12: test_delete_object

 def test_delete_object(self):
     # create object
     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)
     # delete object
     resp, _ = self.object_client.delete_object(self.container_name,
                                                object_name)
     self.assertHeaders(resp, 'Object', 'DELETE')
开发者ID:coreycb,项目名称:tempest,代码行数:10,代码来源:test_object_services.py

示例13: test_get_object_with_if_none_match

    def test_get_object_with_if_none_match(self):
        # get object with if_none_match
        object_name = data_utils.rand_name(name='TestObject')
        data = data_utils.arbitrary_string(10)
        create_md5 = hashlib.md5(data).hexdigest()
        create_metadata = {'Etag': create_md5}
        self.object_client.create_object(self.container_name,
                                         object_name,
                                         data,
                                         metadata=create_metadata)

        list_data = data_utils.arbitrary_string(15)
        list_md5 = hashlib.md5(list_data).hexdigest()
        list_metadata = {'If-None-Match': list_md5}
        resp, body = self.object_client.get_object(
            self.container_name,
            object_name,
            metadata=list_metadata)
        self.assertHeaders(resp, 'Object', 'GET')
        self.assertEqual(body, data)
开发者ID:coreycb,项目名称:tempest,代码行数:20,代码来源:test_object_services.py

示例14: _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 six.moves.xrange(segments)]
        # uploading segments
        for i in six.moves.xrange(segments):
            resp, _ = self.object_client.create_object_segments(
                self.container_name, object_name, i, data_segments[i])

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

示例15: test_upload_valid_object

    def test_upload_valid_object(self):
        """Attempts to uploads an object smaller than the bytes quota."""
        object_name = data_utils.rand_name(name="TestObject")
        data = data_utils.arbitrary_string(QUOTA_BYTES)

        nbefore = self._get_bytes_used()

        resp, _ = self.object_client.create_object(
            self.container_name, object_name, data)
        self.assertHeaders(resp, 'Object', 'PUT')

        nafter = self._get_bytes_used()
        self.assertEqual(nbefore + len(data), nafter)
开发者ID:Dynavisor,项目名称:tempest,代码行数:13,代码来源:test_container_quotas.py


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