author | Julien Cristau <julien.cristau@logilab.fr> |
Tue, 17 Jun 2014 17:53:31 +0200 | |
changeset 10013 | b68088082280 |
parent 9989 | cfb6e9dab902 |
child 10072 | 934341b848a6 |
permissions | -rw-r--r-- |
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') |