cubicweb/devtools/fake.py
changeset 11913 4516c3956d46
parent 11825 52acf0dbf4cd
child 12027 c62c80f20a82
equal deleted inserted replaced
11912:c9e6df20e5a4 11913:4516c3956d46
    32 
    32 
    33 
    33 
    34 class FakeConfig(dict, BaseApptestConfiguration):
    34 class FakeConfig(dict, BaseApptestConfiguration):
    35     translations = {}
    35     translations = {}
    36     uiprops = {}
    36     uiprops = {}
    37     https_uiprops = {}
       
    38     apphome = None
    37     apphome = None
    39     debugmode = False
    38     debugmode = False
    40     def __init__(self, appid='data', apphome=None, cubes=()):
    39     def __init__(self, appid='data', apphome=None, cubes=()):
    41         self.appid = appid
    40         self.appid = appid
    42         self.apphome = apphome
    41         self.apphome = apphome
    44         self['auth-mode'] = 'cookie'
    43         self['auth-mode'] = 'cookie'
    45         self['uid'] = None
    44         self['uid'] = None
    46         self['base-url'] = BASE_URL
    45         self['base-url'] = BASE_URL
    47         self['rql-cache-size'] = 3000
    46         self['rql-cache-size'] = 3000
    48         self.datadir_url = BASE_URL + 'data/'
    47         self.datadir_url = BASE_URL + 'data/'
    49         self.https_datadir_url = (BASE_URL + 'data/').replace('http://', 'https://')
       
    50 
    48 
    51     def cubes(self, expand=False):
    49     def cubes(self, expand=False):
    52         return self._cubes
    50         return self._cubes
    53 
    51 
    54     def sources(self):
    52     def sources(self):
    67     """test implementation of an cubicweb request object"""
    65     """test implementation of an cubicweb request object"""
    68 
    66 
    69     def __init__(self, *args, **kwargs):
    67     def __init__(self, *args, **kwargs):
    70         if not (args or 'vreg' in kwargs):
    68         if not (args or 'vreg' in kwargs):
    71             kwargs['vreg'] = FakeCWRegistryStore(FakeConfig(), initlog=False)
    69             kwargs['vreg'] = FakeCWRegistryStore(FakeConfig(), initlog=False)
    72         kwargs['https'] = False
       
    73         self._http_method = kwargs.pop('method', 'GET')
    70         self._http_method = kwargs.pop('method', 'GET')
    74         self._url = kwargs.pop('url', None)
    71         self._url = kwargs.pop('url', None)
    75         if self._url is None:
    72         if self._url is None:
    76             self._url = 'view?rql=Blop&vid=blop'
    73             self._url = 'view?rql=Blop&vid=blop'
    77         super(FakeRequest, self).__init__(*args, **kwargs)
    74         super(FakeRequest, self).__init__(*args, **kwargs)