web/test/unittest_http_headers.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Sep 2015 08:32:49 +0200
changeset 10637 a8b33789b982
parent 10072 934341b848a6
permissions -rw-r--r--
[autoform] fix appearance of link to add inlined creation form On entity creation, if there are some local permissions on the relation, we have no way of checking them since neither the subject nor the object of the relation exists yet. In such a case, we should add the link by default, for consistency (see other places where we use `may_have_permission`). Closes #6711900

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()