本文整理汇总了Python中dao.UserDao.get_user方法的典型用法代码示例。如果您正苦于以下问题:Python UserDao.get_user方法的具体用法?Python UserDao.get_user怎么用?Python UserDao.get_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.UserDao
的用法示例。
在下文中一共展示了UserDao.get_user方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_008_onMessage_delete_user_ok
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def test_008_onMessage_delete_user_ok(self):
user_delete = testData.USER_DELETE
user_data = json.loads(user_delete['data'])
user_before = UserDao.get_user(user_data['username'])
self.assertIsNotNone(user_before)
SyncManager.onMessage(user_delete)
user_after = UserDao.get_user(user_data['username'])
self.assertIsNone(user_after)
示例2: test_012_test_user_correction_ack
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def test_012_test_user_correction_ack(self):
user_conflict_ack = testData.USER_CORRECTION_ACK
correction = json.loads(user_conflict_ack['correction'])
user_before = UserDao.get_user(correction['username'])
self.assertNotEqual(correction, user_before)
SyncManager.onMessage(user_conflict_ack)
user_after = UserDao.get_user(correction['username'])
self.assertEqual(correction, user_after)
示例3: test_020_put
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def test_020_put(self):
global cherrypy
cherrypy.session = {'roles': ['admin', 'planner', 'driver']}
olduser = UserDao.get_user("username")
self.assertEqual(olduser['email'], "[email protected]")
user.put(olduser['id'], olduser['username'], olduser['surname'], olduser['name'], olduser['number'], olduser['password'], '[email protected]')
changeduser = UserDao.get_user("username")
self.assertEqual(changeduser['name'], "name")
self.assertEqual(changeduser['number'], "1234567890")
self.assertEqual(changeduser['email'], "[email protected]")
示例4: delete_user
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def delete_user(username):
user = UserDao.get_user(username)
if user and authentication.allow_full_user_changes(username):
UserDao.delete_user(username)
user = UserDao.get_user(username)
if not user:
assignees = assigneesHandler.get_customers(username)
for assignee in assignees:
assigneesHandler.delete(assignee.get('user'), assignee.get('customer'))
assignees = assigneesHandler.get_customers('username')
if not assignees or len(assignees) == 0:
return True
return False
示例5: test_007_onMessage_update_user_ok
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def test_007_onMessage_update_user_ok(self):
user_update = testData.USER_UPDATE
config.LOCAL = False
user_before = UserDao.get_user(json.loads(user_update['data'])['username'])
SyncManager.onMessage(user_update)
user_after = UserDao.get_user(json.loads(user_update['data'])['username'])
self.assertNotEquals(user_before['email'], user_after['email'])
self.assertNotEquals(user_before['surname'], user_after['surname'])
self.assertNotEquals(user_before['name'], user_after['name'])
self.assertNotEquals(user_before['phone'], user_after['phone'])
self.assertNotEquals(user_before['password'], user_after['password'])
self.assertNotEquals(user_before['salt'], user_after['salt'])
self.assertEquals(user_before['role'], user_after['role'])
self.assertEquals(user_before['username'], user_after['username'])
self.assertEquals(user_before['burner_sn'], user_after['burner_sn'])
示例6: test_010_test_not_accept_user_update
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def test_010_test_not_accept_user_update(self):
user_update_conflict = testData.USER_UPDATE_CONFLICT
user_conflict_data = json.loads(user_update_conflict['data'])
user_conflict_prev = json.loads(user_update_conflict['prev'])
user_before = UserDao.get_user(user_conflict_data['username'])
self.assertNotEqual(user_before, user_conflict_prev)
config.LOCAL = True
SyncManager.send_correction_ack = MagicMock(return_value="ok")
SyncManager.onMessage(user_update_conflict)
user_after = UserDao.get_user(user_conflict_data['username'])
self.assertEqual(user_before, user_after)
SyncManager.send_correction_ack.assert_called_with(user_update_conflict['id'], user_update_conflict['burner_sn'], user_before)
示例7: test_010_post
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def test_010_post(self):
global cherrypy
cherrypy.session = {'roles': ['admin', 'planner', 'driver']}
user.post("username", "surname", "name", "1234567890", "password", "[email protected]")
createduser = UserDao.get_user("username")
self.assertEqual(createduser['name'], "name")
self.assertEqual(createduser['number'], "1234567890")
self.assertEqual(createduser['username'], "username")
self.assertEqual(createduser['role'], "user")
示例8: get_user
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def get_user(username=None):
current_user = get_current_user()
if not username:
return current_user
else:
user = UserDao.get_user(username)
if user:
user = _set_customers(user)
if authentication.allow_semi_user_changes(user):
return user
示例9: test_005_onMessage_create_user_ok
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def test_005_onMessage_create_user_ok(self):
num_users_before = len(UserDao.get_all())
user_template = testData.USER_CREATE_OK
user_data = json.loads(user_template['data'])
SyncManager.onMessage(user_template)
num_users_after = len(UserDao.get_all())
user_created = UserDao.get_user(user_data['username'])
self.assertEquals(num_users_after, num_users_before + 1)
self.assertEquals(user_created['username'], user_data['username'])
示例10: check_password
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def check_password(username, password):
user = UserDao.get_user(username)
if user is None:
LOG.warning("Failed logon attempt fort " + str(username))
return False
salt = user["salt"]
hashed_password = hashlib.sha512(password.encode("utf-8") + salt.encode("utf-8")).hexdigest()
if user and username == user["username"] and hashed_password == user["password"]:
return user
else:
LOG.warning("Failed logon attempt for " + str(username))
return False
示例11: cookie
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def cookie(self):
request_cookie = cherrypy.request.cookie
cookie_val = request_cookie.get(COOKIE_NAME).value.split('|')
if len(cookie_val) == 2:
username, cookie_id = cookie_val
user = UserDao.get_user(username)
if user.get('cookie_id') and user.get('cookie_expire'):
if user['cookie_id'] == cookie_id and datetime_to_unix(user.get('cookie_expire')) > time.time():
authentication.login(cherrypy.session, user)
return OkResponse('ok')
return ConflictResponse('error')
示例12: test
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def test(user_ids):
# user_ids is an array of ids []
r = redis.Redis()
user_dao = UserDao(r)
for user in user_ids:
got_user = user_dao.get_user(user)
print "Here's a user..."
print got_user.screenname
print got_user.id
print got_user.oauth_token_secret
print got_user.oauth_token
print "-end-"
示例13: test_040_delete
# 需要导入模块: from dao import UserDao [as 别名]
# 或者: from dao.UserDao import get_user [as 别名]
def test_040_delete(self):
global cherrypy
cherrypy.session = {'roles': ['admin', 'planner', 'driver']}
user.delete('username')
deleteduser = UserDao.get_user("username")
self.assertIsNone(deleteduser, "deleted user still exists")