server/test/unittest_querier.py
branchstable
changeset 8342 7a5271182ef0
parent 8317 9c59258e7798
child 8343 6bd8db130476
equal deleted inserted replaced
8341:af813e7d5daa 8342:7a5271182ef0
     1 # -*- coding: iso-8859-1 -*-
     1 # -*- coding: iso-8859-1 -*-
     2 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     3 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     4 #
     4 #
     5 # This file is part of CubicWeb.
     5 # This file is part of CubicWeb.
     6 #
     6 #
     7 # CubicWeb is free software: you can redistribute it and/or modify it under the
     7 # CubicWeb is free software: you can redistribute it and/or modify it under the
    26 from cubicweb import QueryError, Unauthorized, Binary
    26 from cubicweb import QueryError, Unauthorized, Binary
    27 from cubicweb.server.sqlutils import SQL_PREFIX
    27 from cubicweb.server.sqlutils import SQL_PREFIX
    28 from cubicweb.server.utils import crypt_password
    28 from cubicweb.server.utils import crypt_password
    29 from cubicweb.server.sources.native import make_schema
    29 from cubicweb.server.sources.native import make_schema
    30 from cubicweb.devtools import get_test_db_handler, TestServerConfiguration
    30 from cubicweb.devtools import get_test_db_handler, TestServerConfiguration
    31 
    31 from cubicweb.devtools.testlib import CubicWebTC
    32 from cubicweb.devtools.repotest import tuplify, BaseQuerierTC
    32 from cubicweb.devtools.repotest import tuplify, BaseQuerierTC
    33 from unittest_session import Variable
    33 from unittest_session import Variable
    34 
    34 
    35 class FixedOffset(tzinfo):
    35 class FixedOffset(tzinfo):
    36     def __init__(self, hours=0):
    36     def __init__(self, hours=0):
  1499     def test_nonregr_sql_cache(self):
  1499     def test_nonregr_sql_cache(self):
  1500         # different SQL generated when 'name' is None or not (IS NULL).
  1500         # different SQL generated when 'name' is None or not (IS NULL).
  1501         self.assertFalse(self.execute('Any X WHERE X is CWEType, X name %(name)s', {'name': None}))
  1501         self.assertFalse(self.execute('Any X WHERE X is CWEType, X name %(name)s', {'name': None}))
  1502         self.assertTrue(self.execute('Any X WHERE X is CWEType, X name %(name)s', {'name': 'CWEType'}))
  1502         self.assertTrue(self.execute('Any X WHERE X is CWEType, X name %(name)s', {'name': 'CWEType'}))
  1503 
  1503 
       
  1504 class NonRegressionTC(CubicWebTC):
       
  1505     def test_has_text_security_cache_bug(self):
       
  1506         self.create_user('user', ('users',))
       
  1507         req = self.request()
       
  1508         aff1 = req.create_entity('Societe', nom=u'aff1')
       
  1509         aff2 = req.create_entity('Societe', nom=u'aff2')
       
  1510         self.commit()
       
  1511         with self.login('user', password='user'):
       
  1512             res = self.execute('Any X WHERE X has_text %(text)s', {'text': 'aff1'})
       
  1513             self.assertEqual(res.rows, [[aff1.eid]])
       
  1514             res = self.execute('Any X WHERE X has_text %(text)s', {'text': 'aff2'})
       
  1515             self.assertEqual(res.rows, [[aff2.eid]])
  1504 if __name__ == '__main__':
  1516 if __name__ == '__main__':
  1505     unittest_main()
  1517     unittest_main()