Ejemplo n.º 1
0
    def test_user_cannot_login_with_incorrect_password(self):
        """Test that a bad password will not let existing user log in"""
        # add example users
        generate_example_users()

        result = self.app.post('/login',
                               data={'email': '*****@*****.**',
                                     'password': '******'},
                               follow_redirects=True)

        self.assertEqual(result.status_code, 200)
        self.assertIn('text/html', result.headers['Content-Type'])
        self.assertIn('Incorrect password.', result.data)

        db.session.rollback()
Ejemplo n.º 2
0
    def test_unknown_user_cannot_login(self):
        """Test that an unknown user cannot log in"""
        # add example users
        generate_example_users()

        result = self.app.post('/login',
                               data={'email': '*****@*****.**',
                                     'password': '******'},
                               follow_redirects=True)

        self.assertEqual(result.status_code, 200)
        self.assertIn('text/html', result.headers['Content-Type'])
        self.assertIn('You are not registered as a user.', result.data)

        db.session.rollback()
Ejemplo n.º 3
0
    def test_login_existing_user(self):
        """Test that an existing user can login"""
        # add example users
        generate_example_users()

        result = self.app.post('/login',
                               data={'email': '*****@*****.**',
                                     'password': '******'},
                               follow_redirects=True)

        self.assertEqual(result.status_code, 200)
        self.assertIn('text/html', result.headers['Content-Type'])
        self.assertIn('You have logged in.', result.data)

        db.session.rollback()
Ejemplo n.º 4
0
    def setUp(self):
        self.app = app.test_client()
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
        app.config['TESTING'] = True
        app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
        db.app = app
        db.init_app(app)
        db.create_all()

        generate_example_schools()
        generate_example_users()
        generate_example_school_lists()

        # initiate session
        with self.app as c:
            with c.session_transaction() as sess:
                sess['user_id'] = '1'
Ejemplo n.º 5
0
    def test_existing_user_cannot_reregister(self):
        """Test that an existing user cannot reregister"""
        # add example users
        generate_example_users()

        result = self.app.post('/register',
                               data={'email': '*****@*****.**',
                                     'password': '******',
                                     'gpa': 3.0,
                                     'lsat': 165},
                               follow_redirects=True)

        self.assertEqual(result.status_code, 200)
        self.assertIn('text/html', result.headers['Content-Type'])
        self.assertIn('You are already registered.', result.data)

        db.session.rollback()