web/test/unittest_http_headers.py
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 11 Jun 2014 15:32:07 +0200
changeset 10364 8b35a898b334
parent 10072 934341b848a6
permissions -rw-r--r--
[server] remove cnxset tracking, it is now unneeded Indeed, all cnxsets will now be acquired using the following API:: with session.new_cnx() as cnx: cnx.execute(...) # do stuff cnx.commit() These well-scoped blocks are the only place a cnxset can be acquired. The old use-case for un-delimited cnxsets (pyro/zmqpickle protocols) have been removed. The "mode" of connection objects becomes "write" forever (it will be removed in a couple of changesets). Related to #2919309.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9989
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     1
import unittest
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     2
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     3
from cubicweb.web import http_headers
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     4
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     5
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     6
class TestGenerators(unittest.TestCase):
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     7
    def test_generate_true_false(self):
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     8
        for v in (True, 1, 'true', 'True', 'TRUE'):
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
     9
            self.assertEqual('true', http_headers.generateTrueFalse(v))
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    10
        for v in (False, 0, 'false', 'False', 'FALSE'):
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    11
            self.assertEqual('false', http_headers.generateTrueFalse(v))
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    12
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    13
        with self.assertRaises(ValueError):
cfb6e9dab902 [cors] Fix CORS headers generators
Christophe de Vienne <christophe@unlish.com>
parents:
diff changeset
    14
            http_headers.generateTrueFalse('any value')
10072
934341b848a6 [test] missing unittest.main() call in unittest_http_headers.py
David Douard <david.douard@logilab.fr>
parents: 9989
diff changeset
    15
934341b848a6 [test] missing unittest.main() call in unittest_http_headers.py
David Douard <david.douard@logilab.fr>
parents: 9989
diff changeset
    16
if __name__ == '__main__':
934341b848a6 [test] missing unittest.main() call in unittest_http_headers.py
David Douard <david.douard@logilab.fr>
parents: 9989
diff changeset
    17
    from unittest import main
934341b848a6 [test] missing unittest.main() call in unittest_http_headers.py
David Douard <david.douard@logilab.fr>
parents: 9989
diff changeset
    18
    main()