sampleapp/sampleapp/tests.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 01 Jun 2016 17:27:29 +0200
changeset 11628 0f12ee84f30a
parent 11483 7b7ed56bf2fb
permissions -rw-r--r--
Test and fix status code and content of the login form on authentication error The status code was 200 and is now fixed to 403, but the content part of the test will fail until cset 02328f8cbd5c is integrated in cubicweb.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11483
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     1
import unittest
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     2
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     3
from pyramid import testing
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     4
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     5
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     6
class ViewTests(unittest.TestCase):
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     7
    def setUp(self):
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     8
        self.config = testing.setUp()
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     9
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    10
    def tearDown(self):
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    11
        testing.tearDown()
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    12
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    13
    def test_my_view(self):
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    14
        from .views import my_view
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    15
        request = testing.DummyRequest()
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    16
        info = my_view(request)
7b7ed56bf2fb Add a basic sample application
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    17
        self.assertEqual(info['project'], 'cubi')