def test_add_user(self): from quizr.models import User user = User(u'username', u'password', u'name', u'email') self.session.add(user) self.session.flush() user = self.session.query(User).filter(User.username == u'username') user = user.first() self.assertEqual(user.username, u'username') self.assertEqual(user.name, u'name') self.assertEqual(user.email, u'email')
def _addUser(self, username=u'username'): from quizr.models import User user = User(username=username, password=u'password', name=u'name', email=u'email') self.session.add(user) self.session.flush() return user
def test_getting_by_username(self): from quizr.models import User user = self._addUser() self.assertEqual(user, User.get_by_username(u'username'))
def test_password_checking(self): from quizr.models import User self._addUser() self.assertTrue(User.check_password(u'username', u'password')) self.assertFalse(User.check_password(u'username', u'wrong')) self.assertFalse(User.check_password(u'nobody', u'password'))