web/test/unittest_http_headers.py
author Julien Cristau <julien.cristau@logilab.fr>
Tue, 16 Feb 2016 10:52:38 +0100
changeset 11114 468b91aabd9d
parent 10072 934341b848a6
permissions -rw-r--r--
[web/views] fix editcontroller regression unittest_views_basecontrollers.py's EditControllerTC.test_edit_mandatory_inlined3_object regressed with changeset dcbb64d3a1d9 because it relied on POSTing nonexisting eids. This seems like a silly idea, but let's keep the behaviour unchanged.

import unittest

from cubicweb.web import http_headers


class TestGenerators(unittest.TestCase):
    def test_generate_true_false(self):
        for v in (True, 1, 'true', 'True', 'TRUE'):
            self.assertEqual('true', http_headers.generateTrueFalse(v))
        for v in (False, 0, 'false', 'False', 'FALSE'):
            self.assertEqual('false', http_headers.generateTrueFalse(v))

        with self.assertRaises(ValueError):
            http_headers.generateTrueFalse('any value')

if __name__ == '__main__':
    from unittest import main
    main()