本文整理汇总了Python中pyrax.utils.random_name函数的典型用法代码示例。如果您正苦于以下问题:Python random_name函数的具体用法?Python random_name怎么用?Python random_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了random_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, name=None, info=None, *args, **kwargs):
name = name or utils.random_name(ascii_only=True)
info = info or {"fake": "fake"}
super(FakeLoadBalancer, self).__init__(name, info, *args, **kwargs)
self.id = utils.random_name(ascii_only=True)
self.port = random.randint(1, 256)
self.manager = FakeLoadBalancerManager()
开发者ID:naterh,项目名称:pyrax,代码行数:7,代码来源:fakes.py
示例2: 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)
fake_name = utils.random_name()
fake_email = utils.random_name()
fake_username = utils.random_name()
fake_uid = utils.random_name()
fake_region = utils.random_name()
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:216software,项目名称:pyrax,代码行数:26,代码来源:test_identity.py
示例3: 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_name()
fake_email = utils.random_name()
fake_username = utils.random_name()
fake_uid = utils.random_name()
fake_region = utils.random_name()
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:piecommerce,项目名称:pyrax,代码行数:27,代码来源:test_identity.py
示例4: 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_name(), utils.random_name())
sav_stdout = sys.stdout
out = StringIO.StringIO()
sys.stdout = out
utils.add_method(ident, lambda self: "", "_get_auth_endpoint")
dkv = utils.random_name()
data = {dkv: dkv}
jdata = json.dumps(data)
hkv = utils.random_name()
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:216software,项目名称:pyrax,代码行数:31,代码来源:test_identity.py
示例5: test_auth_with_token_rax
def test_auth_with_token_rax(self):
ident = self.rax_identity_class()
mid = utils.random_name()
oid = utils.random_name()
token = utils.random_name()
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:216software,项目名称:pyrax,代码行数:32,代码来源:test_identity.py
示例6: test_clt_resolve_lbs_dict
def test_clt_resolve_lbs_dict(self):
clt = fakes.FakeAutoScaleClient()
key = utils.random_name()
val = utils.random_name()
lb_dict = {key: val}
ret = clt._resolve_lbs(lb_dict)
self.assertEqual(ret, [lb_dict])
开发者ID:lakshmi-kannan,项目名称:pyrax,代码行数:7,代码来源:test_autoscale.py
示例7: test_detach_from_instance_fail
def test_detach_from_instance_fail(self):
vol = self.volume
srv_id = utils.random_name()
att_id = utils.random_name()
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:ExtremeSitting,项目名称:pyrax,代码行数:7,代码来源:test_cloud_blockstorage.py
示例8: test_get_temp_url_missing_key
def test_get_temp_url_missing_key(self):
client = self.client
cname = utils.random_name(ascii_only=True)
oname = utils.random_name(ascii_only=True)
client.connection.head_account = Mock()
client.connection.head_account.return_value = {"some-other-key": "no"}
self.assertRaises(exc.MissingTemporaryURLKey, client.get_temp_url, cname, oname, seconds=120, method="GET")
开发者ID:piecommerce,项目名称:pyrax,代码行数:7,代码来源:test_cf_client.py
示例9: test_http_methods
def test_http_methods(self):
ident = self.base_identity_class()
ident._call = Mock()
uri = utils.random_name()
dkv = utils.random_name()
data = {dkv: dkv}
hkv = utils.random_name()
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:216software,项目名称:pyrax,代码行数:29,代码来源:test_identity.py
示例10: test_snapshot_name_property
def test_snapshot_name_property(self):
snap = self.snapshot
nm = utils.random_name()
snap.display_name = nm
self.assertEqual(snap.name, snap.display_name)
nm = utils.random_name()
snap.name = nm
self.assertEqual(snap.name, snap.display_name)
开发者ID:ExtremeSitting,项目名称:pyrax,代码行数:8,代码来源:test_cloud_blockstorage.py
示例11: test_volume_description_property
def test_volume_description_property(self):
vol = self.volume
nm = utils.random_name()
vol.display_description = nm
self.assertEqual(vol.description, vol.display_description)
nm = utils.random_name()
vol.description = nm
self.assertEqual(vol.description, vol.display_description)
开发者ID:ExtremeSitting,项目名称:pyrax,代码行数:8,代码来源:test_cloud_blockstorage.py
示例12: test_volume_name_property
def test_volume_name_property(self):
vol = self.volume
nm = utils.random_name()
vol.display_name = nm
self.assertEqual(vol.name, vol.display_name)
nm = utils.random_name()
vol.name = nm
self.assertEqual(vol.name, vol.display_name)
开发者ID:ExtremeSitting,项目名称:pyrax,代码行数:8,代码来源:test_cloud_blockstorage.py
示例13: test_client_create_snapshot
def test_client_create_snapshot(self):
clt = self.client
vol = self.volume
name = utils.random_name()
description = utils.random_name()
vol.create_snapshot = Mock()
clt.create_snapshot(vol, name=name, description=description, force=True)
vol.create_snapshot.assert_called_once_with(name=name, description=description, force=True)
开发者ID:ExtremeSitting,项目名称:pyrax,代码行数:8,代码来源:test_cloud_blockstorage.py
示例14: test_create_snapshot
def test_create_snapshot(self):
vol = self.volume
vol._snapshot_manager.create = Mock()
name = utils.random_name()
desc = utils.random_name()
vol.create_snapshot(name=name, description=desc, force=False)
vol._snapshot_manager.create.assert_called_once_with(volume=vol, name=name,
description=desc, force=False)
开发者ID:ExtremeSitting,项目名称:pyrax,代码行数:8,代码来源:test_cloud_blockstorage.py
示例15: test_name
def test_name(self):
sg = self.scaling_group
name = utils.random_name()
newname = utils.random_name()
sg.groupConfiguration = {"name": name}
self.assertEqual(sg.name, name)
sg.name = newname
self.assertEqual(sg.name, newname)
开发者ID:naterh,项目名称:pyrax,代码行数:8,代码来源:test_autoscale.py
示例16: test_auth_with_token
def test_auth_with_token(self):
pyrax.authenticated = False
tok = utils.random_name()
tname = utils.random_name()
pyrax.auth_with_token(tok, tenant_name=tname)
self.assertTrue(pyrax.identity.authenticated)
self.assertEqual(pyrax.identity.token, tok)
self.assertEqual(pyrax.identity.tenant_name, tname)
开发者ID:claco,项目名称:pyrax,代码行数:8,代码来源:test_module.py
示例17: test_mgr_resolve_lbs_dict
def test_mgr_resolve_lbs_dict(self):
sg = self.scaling_group
mgr = sg.manager
key = utils.random_name()
val = utils.random_name()
lb_dict = {key: val}
ret = mgr._resolve_lbs(lb_dict)
self.assertEqual(ret, [lb_dict])
开发者ID:naterh,项目名称:pyrax,代码行数:8,代码来源:test_autoscale.py
示例18: test_revoke_user_access
def test_revoke_user_access(self):
inst = self.instance
fakeuser = utils.random_name(ascii_only=True)
dbname1 = utils.random_name(ascii_only=True)
inst._user_manager.api.method_delete = Mock(return_value=(None, None))
inst.revoke_user_access(fakeuser, dbname1, strict=False)
inst._user_manager.api.method_delete.assert_called_once_with(
"/None/%s/databases/%s" % (fakeuser, dbname1))
开发者ID:andrew-plunk,项目名称:pyrax,代码行数:8,代码来源:test_cloud_databases.py
示例19: test_max_entities
def test_max_entities(self):
sg = self.scaling_group
max_entities = utils.random_name()
newmax_entities = utils.random_name()
sg.groupConfiguration = {"maxEntities": max_entities}
self.assertEqual(sg.max_entities, max_entities)
sg.max_entities = newmax_entities
self.assertEqual(sg.max_entities, newmax_entities)
开发者ID:naterh,项目名称:pyrax,代码行数:8,代码来源:test_autoscale.py
示例20: test_metadata
def test_metadata(self):
sg = self.scaling_group
metadata = utils.random_name()
newmetadata = utils.random_name()
sg.groupConfiguration = {"metadata": metadata}
self.assertEqual(sg.metadata, metadata)
sg.metadata = newmetadata
self.assertEqual(sg.metadata, newmetadata)
开发者ID:naterh,项目名称:pyrax,代码行数:8,代码来源:test_autoscale.py
注:本文中的pyrax.utils.random_name函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论