Esempio n. 1
0
 def test_add_user(self):
     user = User()
     db.session.add(user)
     db.session.commit()
     self.assertIn(user, db.session)
     self.assertTrue(user.is_authenticated())
     self.assertTrue(user.is_active())
     self.assertFalse(user.is_anonymous())
     self.assertEqual(str(user.id), user.get_id())
     db.session.delete(user)
     db.session.commit()
     self.assertNotIn(user, db.session)
Esempio n. 2
0
 def test_add_user(self):
     user = User()
     db.session.add(user)
     db.session.commit()
     assert user in db.session
     assert user.is_authenticated() == True
     assert user.is_active() == True
     assert user.is_anonymous() == False
     assert unicode(user.id) == user.get_id()
     db.session.delete(user)
     db.session.commit()
     assert user not in db.session
Esempio n. 3
0
class UserTestCase(unittest.TestCase):

    def setUp(self):
        self.user = User('mock-name', 'mock-pass')

    def test_is_authenticated(self):
        self.assertTrue(self.user.is_authenticated())

    def test_is_active(self):
        self.user.active = False
        self.assertFalse(self.user.is_active())
        self.user.active = True
        self.assertTrue(self.user.is_active())

    def test_is_anonymous(self):
        self.assertFalse(self.user.is_anonymous())

    def test_get_id(self):
        self.user.id = 123
        self.assertEqual(self.user.id, self.user.get_id())