本文整理汇总了Python中pyrax.utils.random_ascii函数的典型用法代码示例。如果您正苦于以下问题:Python random_ascii函数的具体用法?Python random_ascii怎么用?Python random_ascii使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了random_ascii函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_call
def test_call(self):
ident = self.base_identity_class()
sav_req = pyrax.http.request
pyrax.http.request = Mock()
sav_debug = ident.http_log_debug
ident.http_log_debug = True
uri = "https://%s/%s" % (utils.random_ascii(), utils.random_ascii())
sav_stdout = sys.stdout
out = StringIO.StringIO()
sys.stdout = out
utils.add_method(ident, lambda self: "", "_get_auth_endpoint")
dkv = utils.random_ascii()
data = {dkv: dkv}
hkv = utils.random_ascii()
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)
pyrax.http.request.assert_called_with("POST", uri, body=data,
headers=expected_headers)
self.assertEqual(out.getvalue(), "")
out.seek(0)
out.truncate()
out.close()
pyrax.http.request = sav_req
ident.http_log_debug = sav_debug
sys.stdout = sav_stdout
开发者ID:annegentle,项目名称:pyrax,代码行数:30,代码来源:test_identity.py
示例2: __init__
def __init__(self, name=None, info=None, *args, **kwargs):
name = name or utils.random_ascii()
info = info or {"fake": "fake"}
super(FakeLoadBalancer, self).__init__(name, info, *args, **kwargs)
self.id = utils.random_ascii()
self.port = random.randint(1, 256)
self.manager = FakeLoadBalancerManager()
开发者ID:jasondunsmore,项目名称:heat-pyrax,代码行数:7,代码来源:fakes.py
示例3: test_revoke_user_access
def test_revoke_user_access(self):
inst = self.instance
fakeuser = utils.random_ascii()
dbname1 = utils.random_ascii()
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:CarlFK,项目名称:pyrax,代码行数:8,代码来源:test_cloud_databases.py
示例4: test_get_db_names_fail
def test_get_db_names_fail(self):
inst = self.instance
mgr = inst._user_manager
mgr.instance = inst
dbname1 = utils.random_ascii()
dbname2 = utils.random_ascii()
inst.list_databases = Mock(return_value=((dbname1, dbname2)))
self.assertRaises(exc.NoSuchDatabase, mgr._get_db_names, "BAD")
开发者ID:CarlFK,项目名称:pyrax,代码行数:8,代码来源:test_cloud_databases.py
示例5: test_grant_user_access
def test_grant_user_access(self):
inst = self.instance
fakeuser = utils.random_ascii()
dbname1 = utils.random_ascii()
inst._user_manager.api.method_put = Mock(return_value=(None, None))
inst.grant_user_access(fakeuser, dbname1, strict=False)
inst._user_manager.api.method_put.assert_called_once_with(
"/None/%s/databases" % fakeuser, body={"databases": [{"name":
dbname1}]})
开发者ID:CarlFK,项目名称:pyrax,代码行数:9,代码来源:test_cloud_databases.py
示例6: test_list_user_access
def test_list_user_access(self):
inst = self.instance
dbname1 = utils.random_ascii()
dbname2 = utils.random_ascii()
acc = {"databases": [{"name": dbname1}, {"name": dbname2}]}
inst._user_manager.api.method_get = Mock(return_value=(None, acc))
db_list = inst.list_user_access("fakeuser")
self.assertEqual(len(db_list), 2)
self.assertTrue(db_list[0].name in (dbname1, dbname2))
开发者ID:CarlFK,项目名称:pyrax,代码行数:9,代码来源:test_cloud_databases.py
示例7: test_get_db_names
def test_get_db_names(self):
inst = self.instance
mgr = inst._user_manager
mgr.instance = inst
dbname1 = utils.random_ascii()
dbname2 = utils.random_ascii()
inst.list_databases = Mock(return_value=((dbname1, dbname2)))
resp = mgr._get_db_names(dbname1)
self.assertEqual(resp, [dbname1])
开发者ID:CarlFK,项目名称:pyrax,代码行数:9,代码来源:test_cloud_databases.py
示例8: test_get_db_names_not_strict
def test_get_db_names_not_strict(self):
inst = self.instance
mgr = inst._user_manager
mgr.instance = inst
dbname1 = utils.random_ascii()
dbname2 = utils.random_ascii()
inst.list_databases = Mock(return_value=((dbname1, dbname2)))
resp = mgr._get_db_names("BAD", strict=False)
self.assertEqual(resp, ["BAD"])
开发者ID:CarlFK,项目名称:pyrax,代码行数:9,代码来源:test_cloud_databases.py
示例9: test_download_object
def test_download_object(self):
cont = self.container
cont.client.download_object = Mock()
oname = utils.random_ascii()
dname = utils.random_ascii()
stru = random.choice((True, False))
cont.download_object(oname, dname, structure=stru)
cont.client.download_object.assert_called_once_with(cont, oname,
dname, structure=stru)
开发者ID:Rakkasan,项目名称:pyrax,代码行数:9,代码来源:test_cf_container.py
示例10: test_client_snap_mgr_create_snapshot
def test_client_snap_mgr_create_snapshot(self):
clt = self.client
vol = self.volume
name = utils.random_ascii()
description = utils.random_ascii()
mgr = clt._snapshot_manager
snap = fakes.FakeBlockStorageSnapshot()
mgr._create = Mock(return_value=snap)
ret = mgr.create(name, vol, description=description, force=True)
self.assertTrue(isinstance(ret, CloudBlockStorageSnapshot))
开发者ID:Rakkasan,项目名称:pyrax,代码行数:10,代码来源:test_cloud_blockstorage.py
示例11: test_case_insensitive_update
def test_case_insensitive_update(self):
k1 = utils.random_ascii()
k2 = utils.random_ascii()
k2up = k2.upper()
k3 = utils.random_ascii()
d1 = {k1: "fake", k2up: "fake"}
d2 = {k2: "NEW", k3: "NEW"}
expected = {k1: "fake", k2up: "NEW", k3: "NEW"}
utils.case_insensitive_update(d1, d2)
self.assertEqual(d1, expected)
开发者ID:CarlFK,项目名称:pyrax,代码行数:10,代码来源:test_utils.py
示例12: test_get_temp_url
def test_get_temp_url(self):
cont = self.container
nm = utils.random_ascii()
sav = cont.name
cont.name = utils.random_ascii()
cont.client.get_temp_url = Mock()
secs = random.randint(1, 1000)
cont.get_temp_url(nm, seconds=secs)
cont.client.get_temp_url.assert_called_with(cont, nm, seconds=secs,
method="GET")
cont.name = sav
开发者ID:Rakkasan,项目名称:pyrax,代码行数:11,代码来源:test_cf_container.py
示例13: test_change_user_password
def test_change_user_password(self):
inst = self.instance
fakename = utils.random_ascii()
newpass = utils.random_ascii()
resp = fakes.FakeResponse()
resp.status_code = 202
inst._user_manager.api.method_put = Mock(return_value=(resp, {}))
fakeuser = fakes.FakeDatabaseUser(inst._user_manager, {"name": fakename})
inst._user_manager.get = Mock(return_value=fakeuser)
inst.change_user_password(fakename, newpass)
inst._user_manager.api.method_put.assert_called_once_with(
"/None/%s" % fakename, body={"user": {"password": newpass}})
开发者ID:CarlFK,项目名称:pyrax,代码行数:12,代码来源:test_cloud_databases.py
示例14: test_api_request_missing_clt_id
def test_api_request_missing_clt_id(self):
clt = self.client
uri = utils.random_ascii()
method = utils.random_ascii()
kwargs = {"fake": utils.random_ascii()}
err = exc.BadRequest("400", 'The "Client-ID" header is required.')
clt._time_request = Mock(side_effect=err)
clt.management_url = utils.random_unicode()
id_svc = pyrax.identity
sav = id_svc.authenticate
id_svc.authenticate = Mock()
self.assertRaises(exc.QueueClientIDNotDefined, clt._api_request, uri,
method, **kwargs)
id_svc.authenticate = sav
开发者ID:Rakkasan,项目名称:pyrax,代码行数:14,代码来源:test_queues.py
示例15: test_api_request_other_error
def test_api_request_other_error(self):
clt = self.client
uri = utils.random_ascii()
method = utils.random_ascii()
kwargs = {"fake": utils.random_ascii()}
err = exc.BadRequest("400", "Some other message")
clt._time_request = Mock(side_effect=err)
clt.management_url = utils.random_unicode()
id_svc = pyrax.identity
sav = id_svc.authenticate
id_svc.authenticate = Mock()
self.assertRaises(exc.BadRequest, clt._api_request, uri,
method, **kwargs)
id_svc.authenticate = sav
开发者ID:Rakkasan,项目名称:pyrax,代码行数:14,代码来源:test_queues.py
示例16: setUp
def setUp(self):
pyrax.connect_to_cloudservers = Mock()
pyrax.connect_to_cloud_loadbalancers = Mock()
pyrax.connect_to_cloud_databases = Mock()
pyrax.connect_to_cloud_blockstorage = Mock()
pyrax.connect_to_cloudfiles()
self.client = pyrax.cloudfiles
self.client.connection.head_container = Mock()
self.cont_name = utils.random_ascii()
self.container = self.client.get_container(self.cont_name)
self.obj_name = utils.random_ascii()
self.fake_object = FakeStorageObject(self.client, self.cont_name,
self.obj_name)
self.client._container_cache = {}
self.container.object_cache = {}
开发者ID:Rakkasan,项目名称:pyrax,代码行数:15,代码来源:test_cf_container.py
示例17: test_api_request
def test_api_request(self):
clt = self.client
uri = utils.random_ascii()
method = utils.random_ascii()
kwargs = {"fake": utils.random_ascii()}
fake_resp = utils.random_ascii()
fake_body = utils.random_ascii()
clt._time_request = Mock(return_value=(fake_resp, fake_body))
clt.management_url = utils.random_unicode()
id_svc = pyrax.identity
sav = id_svc.authenticate
id_svc.authenticate = Mock()
ret = clt._api_request(uri, method, **kwargs)
self.assertEqual(ret, (fake_resp, fake_body))
id_svc.authenticate = sav
开发者ID:Rakkasan,项目名称:pyrax,代码行数:15,代码来源:test_queues.py
示例18: test_get_checksum_from_string
def test_get_checksum_from_string(self):
test = utils.random_ascii()
md = hashlib.md5()
md.update(test)
expected = md.hexdigest()
received = utils.get_checksum(test)
self.assertEqual(expected, received)
开发者ID:CarlFK,项目名称:pyrax,代码行数:7,代码来源:test_utils.py
示例19: test_fetch_object
def test_fetch_object(self):
cont = self.container
cont.client.fetch_object = Mock()
oname = utils.random_ascii()
incmeta = random.choice((True, False))
csize = random.randint(0, 1000)
cont.fetch_object(oname, include_meta=incmeta, chunk_size=csize)
cont.client.fetch_object.assert_called_once_with(cont, oname,
include_meta=incmeta, chunk_size=csize)
开发者ID:Rakkasan,项目名称:pyrax,代码行数:9,代码来源:test_cf_container.py
示例20: test_delete_object_in_seconds
def test_delete_object_in_seconds(self):
cont = self.container
cont.client.delete_object_in_seconds = Mock()
secs = random.randint(1, 1000)
obj_name = utils.random_ascii()
cont.delete_object_in_seconds(obj_name, secs)
cont.client.delete_object_in_seconds.assert_called_once_with(cont,
obj_name, secs)
nm = utils.random_ascii()
sav = cont.name
cont.name = utils.random_ascii()
cont.client.get_temp_url = Mock()
secs = random.randint(1, 1000)
cont.get_temp_url(nm, seconds=secs)
cont.client.get_temp_url.assert_called_with(cont, nm, seconds=secs,
method="GET")
cont.name = sav
开发者ID:Rakkasan,项目名称:pyrax,代码行数:18,代码来源:test_cf_container.py
注:本文中的pyrax.utils.random_ascii函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论