def setUp(self): # Initialize functional test framework self.app = webtest.TestApp(self.router) self.logout() # Reset users word = 'Спасибо'.decode('utf-8') self.userS = ReplaceableDict() # Super self.userA = ReplaceableDict() # Active self.userI = ReplaceableDict() # Inactive for userID, valueByKey in enumerate([self.userS, self.userA, self.userI], 1): wordNumber = word + str(userID) valueByKey['username'] = wordNumber valueByKey['password'] = wordNumber valueByKey['nickname'] = wordNumber valueByKey['email'] = wordNumber + '@example.com' valueByKey['is_active'] = userID != 3 valueByKey['is_super'] = userID == 1 user = User( id=userID, username=valueByKey['username'], password=valueByKey['password'], nickname=valueByKey['nickname'], email=valueByKey['email'], is_active=valueByKey['is_active'], is_super=valueByKey['is_super']) db.merge(user) transaction.commit()
def setUp(self): # Initialize functional test framework self.app = webtest.TestApp(self.router) self.logout() # Reset users word = 'Спасибо'.decode('utf-8') self.userS = ReplaceableDict() # Super self.userA = ReplaceableDict() # Active self.userI = ReplaceableDict() # Inactive for userID, valueByKey in enumerate( [self.userS, self.userA, self.userI], 1): wordNumber = word + str(userID) valueByKey['username'] = wordNumber valueByKey['password'] = wordNumber valueByKey['nickname'] = wordNumber valueByKey['email'] = wordNumber + '@example.com' valueByKey['is_active'] = userID != 3 valueByKey['is_super'] = userID == 1 user = User(id=userID, username=valueByKey['username'], password=valueByKey['password'], nickname=valueByKey['nickname'], email=valueByKey['email'], is_active=valueByKey['is_active'], is_super=valueByKey['is_super']) db.merge(user) transaction.commit()
def apply_user_(ticket): 'Finalize a change to a user account' user_ = db.query(User_).filter((User_.ticket == ticket) & ( User_.when_expired >= datetime.datetime.utcnow())).first() if not user_: raise UserException('') # If the ticket is valid, if user_: # Apply the change and reset rejection_count userID = user_.user_id db.merge( User(id=userID, username=user_.username, password_=user_.password_, nickname=user_.nickname, email=user_.email, rejection_count=0, code=make_random_string(CODE_LEN))) region_invalidate(get_properties, None, userID) # Return return user_
def apply_user_(ticket): 'Finalize a change to a user account' user_ = db.query(User_).filter( (User_.ticket == ticket) & (User_.when_expired >= datetime.datetime.utcnow())).first() if not user_: raise UserException('') # If the ticket is valid, if user_: # Apply the change and reset rejection_count userID = user_.user_id db.merge(User( id=userID, username=user_.username, password_=user_.password_, nickname=user_.nickname, email=user_.email, rejection_count=0, code=make_random_string(CODE_LEN))) region_invalidate(get_properties, None, userID) # Return return user_