diff options
| author | jvoisin | 2018-12-16 20:36:02 +0100 |
|---|---|---|
| committer | jvoisin | 2018-12-16 20:36:02 +0100 |
| commit | 19dfe057076a09615c5cc7515f7f50fb99b7e846 (patch) | |
| tree | dad91256c54de838b7cb4dfbeac7ec9f7d9197ba | |
| parent | 2b964566852cc51005999875c645c758ae514295 (diff) | |
Add some tests
| -rw-r--r-- | tests.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..7447554 --- /dev/null +++ b/tests.py | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | import unittest | ||
| 2 | |||
| 3 | import main | ||
| 4 | |||
| 5 | |||
| 6 | class FlaskrTestCase(unittest.TestCase): | ||
| 7 | def setUp(self): | ||
| 8 | main.app.testing = True | ||
| 9 | self.app = main.app.test_client() | ||
| 10 | |||
| 11 | def test_get_root(self): | ||
| 12 | rv = self.app.get('/') | ||
| 13 | self.assertIn(b'mat2-web', rv.data) | ||
| 14 | |||
| 15 | def test_get_download_dangerous_file(self): | ||
| 16 | rv = self.app.get('/download/\..\filename') | ||
| 17 | self.assertEqual(rv.status_code, 302) | ||
| 18 | |||
| 19 | def test_get_download_nonexistant_file(self): | ||
| 20 | rv = self.app.get('/download/non_existant') | ||
| 21 | self.assertEqual(rv.status_code, 302) | ||
| 22 | |||
| 23 | if __name__ == '__main__': | ||
| 24 | unittest.main() | ||
| 25 | |||
