本文整理匯總了Python中libraries.testkit.admin.Admin.get_roles方法的典型用法代碼示例。如果您正苦於以下問題:Python Admin.get_roles方法的具體用法?Python Admin.get_roles怎麽用?Python Admin.get_roles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類libraries.testkit.admin.Admin
的用法示例。
在下文中一共展示了Admin.get_roles方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: rest_scan
# 需要導入模塊: from libraries.testkit.admin import Admin [as 別名]
# 或者: from libraries.testkit.admin.Admin import get_roles [as 別名]
def rest_scan(sync_gateway, db, online, num_docs, user_name, channels):
# Missing ADMIN
# TODO: GET /{db}/_session/{session-id}
# TODO: POST /{db}/_session
# TODO: DELETE /{db}/_session/{session-id}
# TODO: DELETE /{db}/_user/{name}/_session/{session-id}
# TODO: DELETE /{db}/_user/{name}/_session
# TODO: DELETE /{db}/_user/{name}
# TODO: POST /{db}/_role/
# TODO: DELETE /{db}/_role/{name}
# Missing REST
# TODO: POST /{db}/_all_docs
# TODO: DELETE /{db}/{doc}
# TODO: PUT /{db}/{doc}/{attachment}
# TODO: GET /{db}/{doc}/{attachment}
# Missing Local Document
# TODO: DELETE /{db}/{local-doc-id}
# Missing Authentication
# TODO: POST /{db}/_facebook_token
admin = Admin(sync_gateway=sync_gateway)
error_responses = list()
# PUT /{db}/_role/{name}
try:
admin.create_role(db=db, name="radio_stations", channels=["HWOD", "KDWB"])
except HTTPError as e:
log_info((e.response.url, e.response.status_code))
error_responses.append((e.response.url, e.response.status_code))
# GET /{db}/_role
try:
roles = admin.get_roles(db=db)
log_info(roles)
except HTTPError as e:
log_info((e.response.url, e.response.status_code))
error_responses.append((e.response.url, e.response.status_code))
# GET /{db}/_role/{name}
try:
role = admin.get_role(db=db, name="radio_stations")
log_info(role)
except HTTPError as e:
log_info((e.response.url, e.response.status_code))
error_responses.append((e.response.url, e.response.status_code))
# PUT /{db}/_user/{name}
try:
user = admin.register_user(target=sync_gateway, db=db, name=user_name, password="password", channels=channels)
except HTTPError as e:
log_info((e.response.url, e.response.status_code))
error_responses.append((e.response.url, e.response.status_code))
# GET /{db}/_user
try:
users_info = admin.get_users_info(db=db)
log_info(users_info)
except HTTPError as e:
log_info((e.response.url, e.response.status_code))
error_responses.append((e.response.url, e.response.status_code))
# GET /{db}/_user/{name}
try:
user_info = admin.get_user_info(db=db, name=user_name)
log_info(user_info)
except HTTPError as e:
log_info((e.response.url, e.response.status_code))
error_responses.append((e.response.url, e.response.status_code))
# GET /{db}
try:
db_info = admin.get_db_info(db=db)
if not online:
assert db_info["state"] == "Offline"
else:
assert db_info["state"] == "Online"
log_info(db_info)
except HTTPError as e:
log_info((e.response.url, e.response.status_code))
error_responses.append((e.response.url, e.response.status_code))
# Create dummy user to hit endpoint if offline, user creation above will fail
if not online:
user = User(target=sync_gateway, db=db, name=user_name, password="password", channels=channels)
# PUT /{db}/{name}
add_docs_errors = user.add_docs(num_docs=num_docs)
error_responses.extend(add_docs_errors)
# POST /{db}/_bulk_docs
bulk_doc_errors = user.add_docs(num_docs=num_docs, bulk=True)
error_responses.extend(bulk_doc_errors)
#.........這裏部分代碼省略.........