server/test/unittest_storage.py
branchstable
changeset 5109 5cf83b9356d5
parent 5013 ad91f93bbb93
child 5131 88b5ca8da928
equal deleted inserted replaced
5108:8495d580a580 5109:5cf83b9356d5
     3 :organization: Logilab
     3 :organization: Logilab
     4 :copyright: 2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     4 :copyright: 2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     7 """
     7 """
       
     8 
       
     9 from __future__ import with_statement
     8 
    10 
     9 from logilab.common.testlib import unittest_main
    11 from logilab.common.testlib import unittest_main
    10 from cubicweb.devtools.testlib import CubicWebTC
    12 from cubicweb.devtools.testlib import CubicWebTC
    11 
    13 
    12 import os.path as osp
    14 import os.path as osp
    91         fspath = self.execute('Any fspath(D) WHERE F eid %(f)s, F data D',
    93         fspath = self.execute('Any fspath(D) WHERE F eid %(f)s, F data D',
    92                               {'f': f1.eid})[0][0]
    94                               {'f': f1.eid})[0][0]
    93         self.assertEquals(fspath.getvalue(), '/the/path')
    95         self.assertEquals(fspath.getvalue(), '/the/path')
    94 
    96 
    95     def test_source_storage_transparency(self):
    97     def test_source_storage_transparency(self):
    96         self.vreg._loadedmods[__name__] = {}
    98         with self.temporary_appobjects(DummyBeforeHook, DummyAfterHook):
    97         self.vreg.register(DummyBeforeHook)
       
    98         self.vreg.register(DummyAfterHook)
       
    99         try:
       
   100             self.create_file()
    99             self.create_file()
   101         finally:
       
   102             self.vreg.unregister(DummyBeforeHook)
       
   103             self.vreg.unregister(DummyAfterHook)
       
   104 
   100 
   105     def test_source_mapped_attribute_error_cases(self):
   101     def test_source_mapped_attribute_error_cases(self):
   106         ex = self.assertRaises(QueryError, self.execute,
   102         ex = self.assertRaises(QueryError, self.execute,
   107                                'Any X WHERE X data ~= "hop", X is File')
   103                                'Any X WHERE X data ~= "hop", X is File')
   108         self.assertEquals(str(ex), 'can\'t use File.data (X data ILIKE "hop") in restriction')
   104         self.assertEquals(str(ex), 'can\'t use File.data (X data ILIKE "hop") in restriction')