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


Python utils.random_str函数代码示例

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


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

示例1: test_container_get_properties_filtered

    def test_container_get_properties_filtered(self):
        self.skipTest("Server side properties filtering not implemented")
        name = random_str(32)

        res = self._create(name)
        self.assertEqual(res, True)

        # container_get_properties on existing container
        data = self.api.container_get_properties(self.account, name)
        self.assertEqual(data['properties'], {})

        # container_get_properties
        metadata = {
            random_str(32): random_str(32),
            random_str(32): random_str(32),
        }
        self._set_properties(name, metadata)

        # container_get_properties specify key
        key = metadata.keys().pop(0)

        data = self.api.container_get_properties(self.account, name, [key])
        self.assertEqual({key: metadata[key]}, data['properties'])

        # clean
        self._clean(name, True)
开发者ID:GuillaumeDelaporte,项目名称:oio-sds,代码行数:26,代码来源:test_objectstorage.py

示例2: test_lock_unlock

    def test_lock_unlock(self):
        # lock without who
        resp = self.app.post("/v1/rdir/admin/lock",
                             query_string={'vol': self.volume},
                             data=json.dumps({}))
        self.assertEqual(resp.status_code, 400)

        # lock
        who = random_str(64)
        data = {'who': who}
        resp = self.app.post("/v1/rdir/admin/lock",
                             query_string={'vol': self.volume},
                             data=json.dumps(data))
        self.assertEqual(resp.status_code, 204)

        # double lock
        data = {'who': random_str(64)}
        resp = self.app.post("/v1/rdir/admin/lock",
                             query_string={'vol': self.volume},
                             data=json.dumps(data))
        self.assertEqual(resp.status_code, 403)
        self.assertEqual(resp.data, "Already locked by %s" % who)

        # unlock
        resp = self.app.post("/v1/rdir/admin/unlock",
                             query_string={'vol': self.volume})
        self.assertEqual(resp.status_code, 204)
开发者ID:fvennetier,项目名称:oio-sds,代码行数:27,代码来源:test_server.py

示例3: test_container_get_properties

    def test_container_get_properties(self):
        name = random_str(32)

        # container_get_properties on unknown container
        self.assertRaises(
            exc.NoSuchContainer, self.api.container_get_properties,
            self.account, name)

        res = self._create(name)
        self.assertEqual(res, True)

        # container_get_properties on existing container
        data = self.api.container_get_properties(self.account, name)
        self.assertEqual(data['properties'], {})

        # container_get_properties
        metadata = {
            random_str(32): random_str(32),
            random_str(32): random_str(32),
        }
        self._set_properties(name, metadata)

        data = self.api.container_get_properties(self.account, name)
        self.assertEqual(data['properties'], metadata)

        # clean
        self._clean(name, True)

        # container_get_properties on deleted container
        self.assertRaises(
            exc.NoSuchContainer, self.api.container_get_properties,
            self.account, name)
开发者ID:GuillaumeDelaporte,项目名称:oio-sds,代码行数:32,代码来源:test_objectstorage.py

示例4: setUp

    def setUp(self):
        super(TestBlobAuditorFunctional, self).setUp()
        self.namespace = self.conf["namespace"]
        self.account = self.conf["account"]

        self.test_dir = self.conf["sds_path"]

        rawx_num, rawx_path, rawx_addr = self.get_service_url("rawx")
        self.rawx = "http://" + rawx_addr

        self.h = hashlib.new("md5")

        conf = {"namespace": self.namespace}
        self.auditor = BlobAuditorWorker(conf, get_logger(None), None)
        self.container_c = ContainerClient(conf)
        self.blob_c = BlobClient()

        self.ref = random_str(8)

        self.container_c.container_create(self.account, self.ref)

        self.url_rand = random_id(64)

        self.data = random_str(1280)
        self.h.update(self.data)
        self.hash_rand = self.h.hexdigest().lower()

        self.content = TestContent(random_str(6), len(self.data), self.url_rand, 1)

        self.content.id_container = cid_from_name(self.account, self.ref).upper()
        self.chunk = TestChunk(self.content.size, self.url_rand, 0, self.hash_rand)

        self.chunk_url = "%s/%s" % (self.rawx, self.chunk.id_chunk)
        self.chunk_proxy = {"hash": self.chunk.md5, "pos": "0", "size": self.chunk.size, "url": self.chunk_url}

        chunk_meta = {
            "content_path": self.content.path,
            "container_id": self.content.id_container,
            "chunk_method": "plain/nb_copy=3",
            "policy": "TESTPOLICY",
            "id": "0000",
            "version": 1,
            "chunk_id": self.chunk.id_chunk,
            "chunk_pos": self.chunk.pos,
            "chunk_hash": self.chunk.md5,
        }
        self.blob_c.chunk_put(self.chunk_url, chunk_meta, self.data)

        self.chunk_path = (
            self.test_dir
            + "/data/"
            + self.namespace
            + "-rawx-1/"
            + self.chunk.id_chunk[0:3]
            + "/"
            + self.chunk.id_chunk
        )
        self.bad_container_id = "0" * 64
开发者ID:fvennetier,项目名称:oio-sds,代码行数:58,代码来源:test_audit_storage.py

示例5: test_set_properties

 def test_set_properties(self):
     api = self.api
     properties = {random_str(64): random_str(64)}
     resp = FakeAPIResponse()
     api._request = Mock(return_value=(resp, None))
     api.set_properties(self.account, self.name, properties)
     uri = "%s/reference/set_properties" % self.uri_base
     params = {'acct': self.account, 'ref': self.name}
     data = json.dumps({'properties': properties})
     api._request.assert_called_once_with(
         'POST', uri, data=data, params=params, headers=None)
开发者ID:fvennetier,项目名称:oio-sds,代码行数:11,代码来源:test_directory.py

示例6: setUp

    def setUp(self):
        super(TestBlobAuditorFunctional, self).setUp()
        self.namespace = self.conf['namespace']
        self.account = self.conf['account']

        self.test_dir = self.conf['sds_path']

        rawx_num, rawx_path, rawx_addr = self.get_service_url('rawx')
        self.rawx = 'http://' + rawx_addr

        self.h = hashlib.new('md5')

        conf = {"namespace": self.namespace}
        self.auditor = BlobAuditorWorker(conf, get_logger(None), None)
        self.container_c = ContainerClient(conf)
        self.blob_c = BlobClient()

        self.ref = random_str(8)

        self.container_c.container_create(self.account, self.ref)

        self.url_rand = random_id(64)

        self.data = random_str(1280)
        self.h.update(self.data)
        self.hash_rand = self.h.hexdigest().lower()

        self.content = TestContent(
            random_str(6), len(self.data), self.url_rand, 1)

        self.content.id_container = cid_from_name(
            self.account, self.ref).upper()
        self.chunk = TestChunk(self.content.size, self.url_rand, 0,
                               self.hash_rand)

        self.chunk_url = "%s/%s" % (self.rawx, self.chunk.id_chunk)
        self.chunk_proxy = {"hash": self.chunk.md5, "pos": "0",
                            "size": self.chunk.size,
                            "url":  self.chunk_url}

        chunk_meta = {'content_path': self.content.path,
                      'container_id': self.content.id_container,
                      'content_chunkmethod': 'plain/nb_copy=3',
                      'content_policy': 'TESTPOLICY',
                      'content_id': '0000',
                      'content_version': 1,
                      'chunk_id': self.chunk.id_chunk,
                      'chunk_pos': self.chunk.pos}
        self.blob_c.chunk_put(self.chunk_url, chunk_meta, self.data)

        self.chunk_path = self.test_dir + '/data/' + self.namespace + \
            '-rawx-1/' + self.chunk.id_chunk[0:3] + "/" + self.chunk.id_chunk
        self.bad_container_id = '0'*64
开发者ID:GuillaumeDelaporte,项目名称:oio-sds,代码行数:53,代码来源:test_audit_storage.py

示例7: test_container_update

    def test_container_update(self):
        api = self.api

        name = random_str(32)
        key = random_str(32)
        value = random_str(32)
        meta = {key: value}
        resp = FakeAPIResponse()
        api._request = Mock(return_value=(resp, None))
        api.container_update(self.account, name, meta, headers=self.headers)

        data = json.dumps(meta)
        uri = "%s/container/set_properties" % self.uri_base
        params = {'acct': self.account, 'ref': name}
        api._request.assert_called_once_with(
            'POST', uri, data=data, params=params, headers=self.headers)
开发者ID:carriercomm,项目名称:oio-sds,代码行数:16,代码来源:test_objectstorage.py

示例8: test_create_properties

    def test_create_properties(self):
        name = random_str(32)

        metadata = {
            random_str(32): random_str(32),
            random_str(32): random_str(32),
        }
        res = self._create(name, metadata)
        self.assertEqual(res, True)

        data = self._get_properties(name)

        self.assertEqual(data['properties'], metadata)

        # clean
        self._clean(name, True)
开发者ID:fvennetier,项目名称:oio-sds,代码行数:16,代码来源:test_directory.py

示例9: test_object_delete_not_found

 def test_object_delete_not_found(self):
     api = self.api
     name = random_str(32)
     api._request = Mock(side_effect=exceptions.NotFound("No object"))
     self.assertRaises(
         exceptions.NoSuchObject, api.object_delete, self.account,
         self.container, name)
开发者ID:fvennetier,项目名称:oio-sds,代码行数:7,代码来源:test_objectstorage.py

示例10: setUp

 def setUp(self):
     self.endpoint = "http://1.2.3.4:8000"
     self.api = FakeDirectoryAPI("NS", self.endpoint)
     self.account = "AUTH_test"
     self.headers = {"x-req-id": random_id(64)}
     self.uri_base = "NS"
     self.name = random_str(64)
开发者ID:fvennetier,项目名称:oio-sds,代码行数:7,代码来源:test_directory.py

示例11: setUp

 def setUp(self):
     self.api = FakeStorageAPI("NS", "http://1.2.3.4:8000")
     self.account = "test"
     self.container = "fake"
     self.headers = {"x-req-id": random_str(32)}
     self.policy = "THREECOPIES"
     self.uri_base = "NS"
开发者ID:fvennetier,项目名称:oio-sds,代码行数:7,代码来源:test_objectstorage.py

示例12: test_chunk_bad_size

    def test_chunk_bad_size(self):
        self.init_content()
        with open(self.chunk_path, "w") as f:
            f.write(random_str(320))

        self.assertRaises(exc.FaultyChunk, self.auditor.chunk_audit,
                          self.chunk_path)
开发者ID:GuillaumeDelaporte,项目名称:oio-sds,代码行数:7,代码来源:test_audit_storage.py

示例13: test_chunk_corrupted

    def test_chunk_corrupted(self):
        self.init_content()
        with open(self.chunk_path, "w") as f:
            f.write(random_str(1280))

        self.assertRaises(exc.CorruptedChunk, self.auditor.chunk_audit,
                          self.chunk_path)
开发者ID:GuillaumeDelaporte,项目名称:oio-sds,代码行数:7,代码来源:test_audit_storage.py

示例14: test_object_create_no_content_length

 def test_object_create_no_content_length(self):
     api = self.api
     name = random_str(32)
     f = Mock()
     self.assertRaises(
         exceptions.MissingContentLength, api.object_create, self.account,
         self.container, f, obj_name=name)
开发者ID:carriercomm,项目名称:oio-sds,代码行数:7,代码来源:test_objectstorage.py

示例15: test_handle_container_not_found

    def test_handle_container_not_found(self):
        @handle_container_not_found
        def test(self, account, container):
            raise exceptions.NotFound("No container")

        container = random_str(32)
        self.assertRaises(
            exceptions.NoSuchContainer, test, self, self.account, container)
开发者ID:fvennetier,项目名称:oio-sds,代码行数:8,代码来源:test_objectstorage.py


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