cubicweb/devtools/fake.py
branch3.24
changeset 11825 52acf0dbf4cd
parent 11767 432f87a63057
child 11913 4516c3956d46
equal deleted inserted replaced
11824:d7ecf6dab085 11825:52acf0dbf4cd
    53 
    53 
    54     def sources(self):
    54     def sources(self):
    55         return {'system': {'db-driver': 'sqlite'}}
    55         return {'system': {'db-driver': 'sqlite'}}
    56 
    56 
    57 
    57 
       
    58 class FakeCWRegistryStore(CWRegistryStore):
       
    59 
       
    60     def property_value(self, key):
       
    61         if key == 'ui.language':
       
    62             return 'en'
       
    63         assert False
       
    64 
       
    65 
    58 class FakeRequest(ConnectionCubicWebRequestBase):
    66 class FakeRequest(ConnectionCubicWebRequestBase):
    59     """test implementation of an cubicweb request object"""
    67     """test implementation of an cubicweb request object"""
    60 
    68 
    61     def __init__(self, *args, **kwargs):
    69     def __init__(self, *args, **kwargs):
    62         if not (args or 'vreg' in kwargs):
    70         if not (args or 'vreg' in kwargs):
    63             kwargs['vreg'] = CWRegistryStore(FakeConfig(), initlog=False)
    71             kwargs['vreg'] = FakeCWRegistryStore(FakeConfig(), initlog=False)
    64         kwargs['https'] = False
    72         kwargs['https'] = False
    65         self._http_method = kwargs.pop('method', 'GET')
    73         self._http_method = kwargs.pop('method', 'GET')
    66         self._url = kwargs.pop('url', None)
    74         self._url = kwargs.pop('url', None)
    67         if self._url is None:
    75         if self._url is None:
    68             self._url = 'view?rql=Blop&vid=blop'
    76             self._url = 'view?rql=Blop&vid=blop'
   132     def __init__(self, repo=None, user=None, vreg=None):
   140     def __init__(self, repo=None, user=None, vreg=None):
   133         self.repo = repo
   141         self.repo = repo
   134         if vreg is None:
   142         if vreg is None:
   135             vreg = getattr(self.repo, 'vreg', None)
   143             vreg = getattr(self.repo, 'vreg', None)
   136         if vreg is None:
   144         if vreg is None:
   137             vreg = CWRegistryStore(FakeConfig(), initlog=False)
   145             vreg = FakeCWRegistryStore(FakeConfig(), initlog=False)
   138         self.vreg = vreg
   146         self.vreg = vreg
   139         self.cnxset = FakeConnectionsSet()
   147         self.cnxset = FakeConnectionsSet()
   140         self.user = user or FakeUser()
   148         self.user = user or FakeUser()
   141         self.is_internal_session = False
   149         self.is_internal_session = False
   142         self.transaction_data = {}
   150         self.transaction_data = {}
   174     def __init__(self, schema, vreg=None, config=None):
   182     def __init__(self, schema, vreg=None, config=None):
   175         self.eids = {}
   183         self.eids = {}
   176         self._count = 0
   184         self._count = 0
   177         self.schema = schema
   185         self.schema = schema
   178         self.config = config or FakeConfig()
   186         self.config = config or FakeConfig()
   179         self.vreg = vreg or CWRegistryStore(self.config, initlog=False)
   187         self.vreg = vreg or FakeCWRegistryStore(self.config, initlog=False)
   180         self.vreg.schema = schema
   188         self.vreg.schema = schema
   181 
   189 
   182     def internal_session(self):
   190     def internal_session(self):
   183         return FakeSession(self)
   191         return FakeSession(self)
   184 
   192