Created
November 23, 2012 12:32
-
-
Save ismaild/4135430 to your computer and use it in GitHub Desktop.
tests for flask
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask | |
| app = Flask(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import render_template | |
| from charts import sites_charts | |
| from dashboard import app | |
| @app.route('/sites') | |
| def site_dashboard(): | |
| return render_template('dashboard.html', object_list=sites_charts) | |
| @app.route('/') | |
| def hello(): | |
| return render_template('home.html') | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| F | |
| ====================================================================== | |
| FAIL: test_no_data (__main__.DashTestCase) | |
| ---------------------------------------------------------------------- | |
| Traceback (most recent call last): | |
| File "tests.py", line 16, in test_no_data | |
| assert 'PLACEHOLDER' in rv.data | |
| AssertionError | |
| ---------------------------------------------------------------------- | |
| Ran 1 test in 0.012s | |
| FAILED (failures=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import dashboard | |
| import unittest | |
| class DashTestCase(unittest.TestCase): | |
| def setUp(self): | |
| dashboard.app.config['TESTING'] = True | |
| self.app = dashboard.app.test_client() | |
| print self.app | |
| def tearDown(self): | |
| pass | |
| def test_no_data(self): | |
| rv = self.app.get('/') | |
| assert 'placeholder' in rv.data | |
| if __name__ == '__main__': | |
| unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment