-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_flask.py
More file actions
33 lines (23 loc) · 882 Bytes
/
Copy pathtest_flask.py
File metadata and controls
33 lines (23 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from unittest2 import TestCase
from flask import url_for
from learnpython.app import app
class TestViews(TestCase):
def setUp(self):
app.testing = True
self.client = app.test_client()
self._ctx = app.test_request_context()
self._ctx.push()
def tearDown(self):
self._ctx.pop()
def test_index(self):
index_url = url_for('index')
response = self.client.get(index_url)
self.assertEqual(response.status_code, 200)
self.assertIn('Learn Python', response.data)
def test_static(self):
url = url_for('static', filename='css/screen.css')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
url = url_for('static', filename='does_not_exists.exe')
response = self.client.get(url)
self.assertEqual(response.status_code, 404)