Esempio n. 1
0
    def test_schools_alpha_list_page(self):
        """test that alphabetical school list page generates from template/db"""
        # add schools to db for testing purposes
        generate_example_schools()

        result = self.app.get('/schools')

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

        db.session.rollback()
Esempio n. 2
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'