def test_create_tables(self): """Test that model.create_tables correctly creates all database tables.""" self.assertRaises(OperationalError, User.by_user_name, u'test') create_tables() assert _create_test_user() create_tables() assert User.by_user_name(u'creosote') create_tables(drop_all=True) try: user = User.by_user_name(u'creosote') except SQLObjectNotFound: user = None assert user is None
def check_user(pseudo, password): """ Check is couple pseudo/password match an user. @params pseudo user's pseudo @params passwd user's password @return null if it does not match, User object otherwise. """ user = User.filter_by(pseudo=pseudo)
def test_create_default_user(self): "Test that the default user is created correctly" create_tables() create_default_user(u'creosote', u'secret') retrieved_user = User.by_email_address(u'*****@*****.**' % u'creosote') assert retrieved_user assert retrieved_user.user_name == u'creosote' assert retrieved_user.display_name == u'Default User' assert retrieved_user.password
def test_user_creation(self): """Object creation should set the name.""" obj = _create_test_user() retrieved_user = User.by_email_address(u'*****@*****.**') assert retrieved_user, \ 'User should have been found by email address' assert retrieved_user.user_name == u'creosote', \ "User name should have been creosote, not '%s'" % retrieved_user.user_name assert obj.display_name == u"Mr Creosote"
def reset_all(json_file): db.drop_all() db.create_all() items = json.loads(open(json_file).read()) for item in items['bookmarks']: i = ItemBookmark(**item) add_bookmark(i) for item in items['users']: i = User(**item) add_user(i)
def validate(self): rv = Form.validate(self) if not rv: return False pseudo = self.login.data password = self.password.data password_confirmation = self.password_confirmation.data if password != password_confirmation: self.password.errors.append('Passwords mismatch') self.password_confirmation.errors.append('Passwords mismatch') return False self.user = User(pseudo, password) return True