[web/facet] Use an Exists node in HasRelationFacet
The generated RQL now includes an EXISTS clause. For instance, one gets:
::
DISTINCT Any WHERE X is CWUser, EXISTS(X in_group A)
instead of:
::
DISTINCT Any WHERE X is CWUser, X in_group A
for a HasRelationFacet with ``rtype = 'in_group'``, which is more appropriate
for testing the existence of the relation.
Add a test for this facet along the way.
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()