summaryrefslogtreecommitdiff
path: root/docs/narr/myproject/tests/test_it.py
blob: b300da34db86670b965fcba6cd9e9a62590f547a (plain)
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
34
35
36
37
38
39
import unittest

from pyramid import testing


class ViewTests(unittest.TestCase):
    def setUp(self):
        self.config = testing.setUp()

    def tearDown(self):
        testing.tearDown()

    def test_my_view(self):
        from myproject.views.default import my_view
        request = testing.DummyRequest()
        info = my_view(request)
        self.assertEqual(info['project'], 'myproject')

    def test_notfound_view(self):
        from myproject.views.notfound import notfound_view
        request = testing.DummyRequest()
        info = notfound_view(request)
        self.assertEqual(info, {})


class FunctionalTests(unittest.TestCase):
    def setUp(self):
        from myproject import main
        app = main({})
        from webtest import TestApp
        self.testapp = TestApp(app)

    def test_root(self):
        res = self.testapp.get('/', status=200)
        self.assertTrue(b'Pyramid' in res.body)

    def test_notfound(self):
        res = self.testapp.get('/badurl', status=404)
        self.assertTrue(res.status_code == 404)