本文整理匯總了Python中API.APIPermissions.add_user方法的典型用法代碼示例。如果您正苦於以下問題:Python APIPermissions.add_user方法的具體用法?Python APIPermissions.add_user怎麽用?Python APIPermissions.add_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類API.APIPermissions
的用法示例。
在下文中一共展示了APIPermissions.add_user方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_user_remove_user_by_id_succeed
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_user [as 別名]
def test_user_remove_user_by_id_succeed(self):
usr = User('[email protected]')
usr.set_nickname('Somebodyruis')
usr.set_user_id('SomeUserid1234ruis')
ps.add_user(usr)
self.assertTrue(ps.remove_user_by_id('SomeUserid1234ruis'))
示例2: test_user_get_user_by_id_succeed
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_user [as 別名]
def test_user_get_user_by_id_succeed(self):
usr = User('[email protected]')
usr.set_nickname('Somebodyguis')
usr.set_user_id('SomeUserid1234guis')
ps.add_user(usr)
self.assertEqual(ps.get_user_by_id('SomeUserid1234guis').email(), usr.email())
示例3: test_user_modify_user_by_id_succeed
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_user [as 別名]
def test_user_modify_user_by_id_succeed(self):
usr = User('[email protected]')
usr.set_nickname('Somebodymids')
usr.set_user_id('SomeUserid1234mids')
ps.add_user(usr)
newusr = User('[email protected]')
newusr.set_nickname('SomebodyElsemids')
newusr.set_user_id('SomeUotherId3878mids')
key = ps.modify_user_by_id('SomeUserid1234mids',newusr)
self.assertEqual(ps.get_user_by_key(key).email(), newusr.email())
示例4: test_user_add_user
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_user [as 別名]
def test_user_add_user(self):
usr = User('[email protected]')
usr.set_nickname('Somebodyau')
usr.set_user_id('SomeUserid1234au')
ret = ps.add_user(usr)
self.assertTrue(isinstance(ret, ndb.Key))
示例5: test_user_get_user_key_by_id
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_user [as 別名]
def test_user_get_user_key_by_id(self):
usr = User('[email protected]')
usr.set_nickname('Somebodyguki')
usr.set_user_id('SomeUserid1234guki')
key = ps.add_user(usr)
self.assertEqual(key,ps.get_user_key_by_id("SomeUserid1234guki"))
示例6: signup_handler
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_user [as 別名]
def signup_handler(request):
authed_user = auth.get_current_user()
if authed_user is None:
return __unauthed_response()
user_key = ps.get_user_key_by_id(authed_user.user_id())
if user_key is None:
user_key = ps.add_user(authed_user)
response_part = {
'success' : False
}
try:
file_req = json.loads(request.raw_post_data)
except ValueError:
response_part.update({'error' : 'Invalid request payload.'})
return HttpResponse(json.dumps(response_part), content_type="application/json")
if 'action' not in file_req:
response_part.update({'error' : 'Incomplete request.'})
return HttpResponse(json.dumps(response_part), content_type="application/json")
elem_key = ps.get_element_key_by_ref('canLogIn')
if elem_key is None:
elem_key = ps.add_element('canLogIn')
user_elem = ps.get_user_element_permissions(user_key, elem_key)
if user_elem is not None:
response_part.update({'error' : 'Already signed up.'})
return HttpResponse(json.dumps(response_part), content_type="application/json")
else:
ps.add_element_permissions(user_key, elem_key, True)
response_part.update({'success' : True})
return HttpResponse(json.dumps(response_part), content_type="application/json")