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

Python utils.random_unicode函数代码示例

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

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



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

示例1: test_findall

 def test_findall(self):
     mgr = self.client._manager
     mgr.findall = Mock()
     prop = utils.random_unicode()
     val = utils.random_unicode()
     self.client.findall(prop=val)
     mgr.findall.assert_called_once_with(prop=val)
开发者ID:abhikalakuntla,项目名称:pyrax,代码行数:7,代码来源:test_client.py


示例2: test_update_user

 def test_update_user(self):
     ident = self.rax_identity_class()
     resp = fakes.FakeIdentityResponse()
     resp.response_type = "users"
     ident.method_put = Mock(return_value=resp)
     fake_name = utils.random_unicode()
     fake_email = utils.random_unicode()
     fake_username = utils.random_unicode()
     fake_uid = utils.random_unicode()
     fake_region = utils.random_unicode()
     fake_enabled = random.choice((True, False))
     ident.update_user(
         fake_name,
         email=fake_email,
         username=fake_username,
         uid=fake_uid,
         defaultRegion=fake_region,
         enabled=fake_enabled,
     )
     cargs = ident.method_put.call_args
     self.assertEqual(len(cargs), 2)
     self.assertEqual(cargs[0], ("users/%s" % fake_name,))
     data = cargs[1]["data"]["user"]
     self.assertEqual(data["enabled"], fake_enabled)
     self.assertEqual(data["username"], fake_username)
     self.assert_(fake_email in data.values())
     self.assert_(fake_region in data.values())
开发者ID:krues8dr,项目名称:pyrax,代码行数:27,代码来源:test_identity.py


示例3: test_create_body_volume_defaults

 def test_create_body_volume_defaults(self):
     mgr = self.client._manager
     size = random.randint(MIN_SIZE, MAX_SIZE)
     name = utils.random_unicode()
     snapshot_id = utils.random_unicode()
     display_description = utils.random_unicode()
     volume_type = utils.random_unicode()
     metadata = {}
     availability_zone = utils.random_unicode()
     fake_body = {
         "volume": {
             "size": size,
             "snapshot_id": snapshot_id,
             "display_name": name,
             "display_description": display_description,
             "volume_type": volume_type,
             "metadata": metadata,
             "availability_zone": availability_zone,
         }
     }
     ret = mgr._create_body(
         name=name,
         size=size,
         volume_type=volume_type,
         description=display_description,
         metadata=metadata,
         snapshot_id=snapshot_id,
         availability_zone=availability_zone,
     )
     self.assertEqual(ret, fake_body)
开发者ID:ephur,项目名称:pyrax,代码行数:30,代码来源:test_cloud_blockstorage.py


示例4: test_img_member_mgr_create_body

 def test_img_member_mgr_create_body(self):
     img = self.image
     mgr = img._member_manager
     nm = utils.random_unicode()
     project_id = utils.random_unicode()
     ret = mgr._create_body(nm, project_id)
     self.assertEqual(ret, {"member": project_id})
开发者ID:rackspace,项目名称:pyrax,代码行数:7,代码来源:test_image.py


示例5: test_detach_from_instance_fail

 def test_detach_from_instance_fail(self):
     vol = self.volume
     srv_id = utils.random_unicode()
     att_id = utils.random_unicode()
     vol.attachments = [{"server_id": srv_id, "id": att_id}]
     vol._nova_volumes.delete_server_volume = Mock(side_effect=Exception("test"))
     self.assertRaises(exc.VolumeDetachmentFailed, vol.detach)
开发者ID:ephur,项目名称:pyrax,代码行数:7,代码来源:test_cloud_blockstorage.py


示例6: test_call

 def test_call(self):
     ident = self.base_identity_class()
     sav_post = requests.post
     requests.post = Mock()
     sav_debug = ident.http_log_debug
     ident.http_log_debug = True
     uri = "https://%s/%s" % (utils.random_unicode(), utils.random_unicode())
     sav_stdout = sys.stdout
     out = StringIO.StringIO()
     sys.stdout = out
     utils.add_method(ident, lambda self: "", "_get_auth_endpoint")
     dkv = utils.random_unicode()
     data = {dkv: dkv}
     jdata = json.dumps(data)
     hkv = utils.random_unicode()
     headers = {hkv: hkv}
     for std_headers in (True, False):
         expected_headers = ident._standard_headers() if std_headers else {}
         expected_headers.update(headers)
         for admin in (True, False):
             ident.method_post(uri, data=data, headers=headers,
                     std_headers=std_headers, admin=admin)
             requests.post.assert_called_with(uri, data=jdata,
                     headers=expected_headers, verify=True)
             self.assertTrue(out.getvalue())
             out.seek(0)
             out.truncate()
     out.close()
     requests.post = sav_post
     ident.http_log_debug = sav_debug
     sys.stdout = sav_stdout
开发者ID:Gu1,项目名称:pyrax,代码行数:31,代码来源:test_identity.py


示例7: test_create_snapshot

 def test_create_snapshot(self):
     vol = self.volume
     vol.manager.create_snapshot = Mock()
     name = utils.random_unicode()
     desc = utils.random_unicode()
     vol.create_snapshot(name=name, description=desc, force=False)
     vol.manager.create_snapshot.assert_called_once_with(volume=vol, name=name, description=desc, force=False)
开发者ID:ephur,项目名称:pyrax,代码行数:7,代码来源:test_cloud_blockstorage.py


示例8: test_auth_with_token_rax

    def test_auth_with_token_rax(self):
        ident = self.rax_identity_class()
        mid = utils.random_unicode()
        oid = utils.random_unicode()
        token = utils.random_unicode()

        class FakeResp(object):
            info = None

            def json(self):
                return self.info

        resp_main = FakeResp()
        resp_main.info = {"access": {
                "serviceCatalog": [{"a": "a", "name": "a", "type": "a"}],
                "user": {"roles":
                        [{"tenantId": oid, "name": "object-store:default"}],
                }}}
        resp_obj = FakeResp()
        resp_obj.info = {"access": {
                "serviceCatalog": [{"b": "b", "name": "b", "type": "b"}]}}
        ident._call_token_auth = Mock(side_effect=(resp_main, resp_obj))

        def fake_parse(dct):
            svcs = dct.get("access", {}).get("serviceCatalog", {})
            pyrax.services = [svc["name"] for svc in svcs]

        ident._parse_response = fake_parse
        ident.auth_with_token(token, tenant_id=mid)
        ident._call_token_auth.assert_called_with(token, oid, None)
        self.assertTrue("a" in pyrax.services)
        self.assertTrue("b" in pyrax.services)
开发者ID:annegentle,项目名称:pyrax,代码行数:32,代码来源:test_identity.py


示例9: __init__

 def __init__(self, *args, **kwargs):
     id_ = utils.random_unicode()
     href = "http://example.com/%s" % id_
     info = kwargs.pop("info", {"href": href})
     info["name"] = utils.random_unicode()
     mgr = kwargs.pop("manager", FakeQueueManager())
     super(FakeQueueMessage, self).__init__(manager=mgr, info=info, *args, **kwargs)
开发者ID:JamesX88,项目名称:tes,代码行数:7,代码来源:fakes.py


示例10: test_create_body_volume

 def test_create_body_volume(self):
     mgr = self.client._manager
     size = random.randint(MIN_SIZE, MAX_SIZE)
     name = utils.random_unicode()
     snapshot_id = utils.random_unicode()
     clone_id = utils.random_unicode()
     display_description = None
     volume_type = None
     metadata = None
     availability_zone = utils.random_unicode()
     fake_body = {"volume": {
             "size": size,
             "snapshot_id": snapshot_id,
             "source_volid": clone_id,
             "display_name": name,
             "display_description": "",
             "volume_type": "SATA",
             "metadata": {},
             "availability_zone": availability_zone,
             }}
     ret = mgr._create_body(name=name, size=size, volume_type=volume_type,
             description=display_description, metadata=metadata,
             snapshot_id=snapshot_id, clone_id=clone_id,
             availability_zone=availability_zone)
     self.assertEqual(ret, fake_body)
开发者ID:Rakkasan,项目名称:pyrax,代码行数:25,代码来源:test_cloud_blockstorage.py


示例11: test_queue_post_message

 def test_queue_post_message(self):
     q = self.queue
     q._message_manager.create = Mock()
     body = utils.random_unicode()
     ttl = utils.random_unicode()
     q.post_message(body, ttl)
     q._message_manager.create.assert_called_once_with(body, ttl)
开发者ID:Rakkasan,项目名称:pyrax,代码行数:7,代码来源:test_queues.py


示例12: test_update_user

 def test_update_user(self):
     for cls in self.id_classes.values():
         ident = cls()
         resp = fakes.FakeIdentityResponse()
         resp.response_type = "users"
         ident.method_put = Mock(return_value=(resp, resp.json()))
         fake_name = utils.random_unicode()
         fake_email = utils.random_unicode()
         fake_username = utils.random_unicode()
         fake_uid = utils.random_unicode()
         fake_region = utils.random_unicode()
         fake_enabled = random.choice((True, False))
         kwargs = {"email": fake_email, "username": fake_username,
                 "uid": fake_uid, "enabled": fake_enabled}
         if isinstance(ident, self.rax_identity_class):
             kwargs["defaultRegion"] = fake_region
         ident.update_user(fake_name, **kwargs)
         cargs = ident.method_put.call_args
         self.assertEqual(len(cargs), 2)
         self.assertEqual(cargs[0], ("users/%s" % fake_name, ))
         data = cargs[1]["data"]["user"]
         self.assertEqual(data["enabled"], fake_enabled)
         self.assertEqual(data["username"], fake_username)
         self.assert_(fake_email in data.values())
         if isinstance(ident, self.rax_identity_class):
             self.assert_(fake_region in data.values())
开发者ID:annegentle,项目名称:pyrax,代码行数:26,代码来源:test_identity.py


示例13: test_imgmgr_create_body

 def test_imgmgr_create_body(self):
     clt = self.client
     mgr = clt._manager
     nm = utils.random_unicode()
     meta = utils.random_unicode()
     body = mgr._create_body(nm, metadata=meta)
     self.assertEqual(body, {"metadata": meta})
开发者ID:rackspace,项目名称:pyrax,代码行数:7,代码来源:test_image.py


示例14: test_http_methods

 def test_http_methods(self):
     ident = self.base_identity_class()
     ident._call = Mock()
     uri = utils.random_unicode()
     dkv = utils.random_unicode()
     data = {dkv: dkv}
     hkv = utils.random_unicode()
     headers = {hkv: hkv}
     std_headers = True
     ident.method_get(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with(requests.get, uri, False, data, headers,
             std_headers)
     ident.method_head(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with(requests.head, uri, False, data, headers,
             std_headers)
     ident.method_post(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with(requests.post, uri, False, data, headers,
             std_headers)
     ident.method_put(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with(requests.put, uri, False, data, headers,
             std_headers)
     ident.method_delete(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with(requests.delete, uri, False, data,
             headers, std_headers)
开发者ID:Gu1,项目名称:pyrax,代码行数:29,代码来源:test_identity.py


示例15: test_queue_mgr_create_body

 def test_queue_mgr_create_body(self):
     clt = self.client
     mgr = clt._manager
     name = utils.random_unicode()
     metadata = utils.random_unicode()
     ret = mgr._create_body(name, metadata=metadata)
     self.assertEqual(ret, {"metadata": metadata})
开发者ID:Rakkasan,项目名称:pyrax,代码行数:7,代码来源:test_queues.py


示例16: test_img_update

 def test_img_update(self):
     img = self.image
     key = utils.random_unicode()
     val = utils.random_unicode()
     img.manager.update = Mock()
     img.update({key: val})
     img.manager.update.assert_called_once_with(img, {key: val})
开发者ID:rackspace,项目名称:pyrax,代码行数:7,代码来源:test_image.py


示例17: test_claim

 def test_claim(self):
     msgs = []
     num = random.randint(1, 9)
     for ii in range(num):
         msg_id = utils.random_unicode()
         claim_id = utils.random_unicode()
         age = utils.random_unicode()
         body = utils.random_unicode()
         ttl = utils.random_unicode()
         href = "http://example.com/%s" % msg_id
         info = {"href": href,
                 "age": age,
                 "body": body,
                 "ttl": ttl,
                 }
         msgs.append(info)
     id_ = _safe_id()
     href = "http://example.com/%s" % id_
     info = {"href": href,
             "messages": msgs,
             }
     mgr = fakes.FakeQueueManager()
     mgr._message_manager = fakes.FakeQueueManager()
     clm = QueueClaim(manager=mgr, info=info)
     self.assertEqual(clm.id, id_)
     self.assertEqual(len(clm.messages), num)
开发者ID:Rakkasan,项目名称:pyrax,代码行数:26,代码来源:test_queues.py


示例18: test_http_methods

 def test_http_methods(self):
     ident = self.base_identity_class()
     ident._call = Mock()
     uri = utils.random_unicode()
     dkv = utils.random_unicode()
     data = {dkv: dkv}
     hkv = utils.random_unicode()
     headers = {hkv: hkv}
     std_headers = True
     ident.method_get(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with("GET", uri, False, data, headers,
             std_headers)
     ident.method_head(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with("HEAD", uri, False, data, headers,
             std_headers)
     ident.method_post(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with("POST", uri, False, data, headers,
             std_headers)
     ident.method_put(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with("PUT", uri, False, data, headers,
             std_headers)
     ident.method_delete(uri, admin=False, data=data, headers=headers,
             std_headers=std_headers)
     ident._call.assert_called_with("DELETE", uri, False, data,
             headers, std_headers)
开发者ID:annegentle,项目名称:pyrax,代码行数:29,代码来源:test_identity.py


示例19: test_snapshot_name_property

 def test_snapshot_name_property(self):
     snap = self.snapshot
     nm = utils.random_unicode()
     snap.display_name = nm
     self.assertEqual(snap.name, snap.display_name)
     nm = utils.random_unicode()
     snap.name = nm
     self.assertEqual(snap.name, snap.display_name)
开发者ID:Rakkasan,项目名称:pyrax,代码行数:8,代码来源:test_cloud_blockstorage.py


示例20: test_volume_description_property

 def test_volume_description_property(self):
     vol = self.volume
     nm = utils.random_unicode()
     vol.display_description = nm
     self.assertEqual(vol.description, vol.display_description)
     nm = utils.random_unicode()
     vol.description = nm
     self.assertEqual(vol.description, vol.display_description)
开发者ID:Rakkasan,项目名称:pyrax,代码行数:8,代码来源:test_cloud_blockstorage.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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