commit | author | age
|
b1b922
|
1 |
import unittest |
PE |
2 |
|
|
3 |
from pyramid import testing |
|
4 |
|
|
5 |
|
|
6 |
class TutorialViewTests(unittest.TestCase): |
|
7 |
def setUp(self): |
|
8 |
self.config = testing.setUp() |
|
9 |
|
|
10 |
def tearDown(self): |
|
11 |
testing.tearDown() |
|
12 |
|
|
13 |
def test_home(self): |
|
14 |
from .views import TutorialViews |
|
15 |
|
|
16 |
request = testing.DummyRequest() |
|
17 |
inst = TutorialViews(request) |
|
18 |
response = inst.home() |
|
19 |
self.assertEqual('Home View', response['name']) |
|
20 |
|
|
21 |
def test_hello(self): |
|
22 |
from .views import TutorialViews |
|
23 |
|
|
24 |
request = testing.DummyRequest() |
|
25 |
inst = TutorialViews(request) |
|
26 |
response = inst.hello() |
|
27 |
self.assertEqual('Hello View', response['name']) |
|
28 |
|
|
29 |
|
|
30 |
class TutorialFunctionalTests(unittest.TestCase): |
|
31 |
def setUp(self): |
|
32 |
from tutorial import main |
|
33 |
app = main({}) |
|
34 |
from webtest import TestApp |
|
35 |
|
|
36 |
self.testapp = TestApp(app) |
|
37 |
|
|
38 |
def test_home(self): |
|
39 |
res = self.testapp.get('/', status=200) |
|
40 |
self.assertIn(b'<h1>Hi Home View', res.body) |
|
41 |
|
|
42 |
def test_hello(self): |
|
43 |
res = self.testapp.get('/howdy', status=200) |
|
44 |
self.assertIn(b'<h1>Hi Hello View', res.body) |
a9e8ac
|
45 |
|
SP |
46 |
def test_css(self): |
|
47 |
res = self.testapp.get('/static/app.css', status=200) |
|
48 |
self.assertIn(b'body', res.body) |