comparison MoinMoin/request/request_cli.py @ 4027:0d6724b87856

Refactored TestConfig creation for py.test based unit tests. The method used before had multiple problems: config creation did not use inheritance (as it does when used the wiki in production). It also didn't do the post processing done in __init__ of Config class. Also, it first created the request with some default config, then created the TestConfig (but some stuff in request was not initialized correctly)... The new method now uses config inheritance in the same way as a production wiki does. The TestConfig instance is created in RequestBase __init__, it does not use sys.path any more to import the test wikiconfig, but does an absolute import from MoinMoin._tests.wikiconfig. TODO: * fix the failing test_pysupport.TestImportExisting.testExisting * auth tests are currently skipped because they need more work * find a better way than staticmethod(TestConfig)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 24 Aug 2008 02:01:34 +0200
parents fee546fba271
children 84c05e657b47
comparison
equal deleted inserted replaced
4026:d3c2d8d89959 4027:0d6724b87856
14 from MoinMoin.request import RequestBase, RemoteClosedConnection 14 from MoinMoin.request import RequestBase, RemoteClosedConnection
15 15
16 class Request(RequestBase): 16 class Request(RequestBase):
17 """ specialized on command line interface and script requests """ 17 """ specialized on command line interface and script requests """
18 18
19 def __init__(self, url='CLI', pagename='', properties={}): 19 def __init__(self, url='CLI', pagename='', properties={}, given_config=None):
20 self.saved_cookie = '' 20 self.saved_cookie = ''
21 self.path_info = '/' + pagename 21 self.path_info = '/' + pagename
22 self.query_string = '' 22 self.query_string = ''
23 self.remote_addr = '127.0.0.1' 23 self.remote_addr = '127.0.0.1'
24 self.is_ssl = 0 24 self.is_ssl = 0
30 self.http_referer = '' 30 self.http_referer = ''
31 self.script_name = '.' 31 self.script_name = '.'
32 self.content_length = None 32 self.content_length = None
33 self.if_modified_since = None 33 self.if_modified_since = None
34 self.if_none_match = None 34 self.if_none_match = None
35 RequestBase.__init__(self, properties) 35 RequestBase.__init__(self, properties, given_config)
36 self.cfg.caching_formats = [] # don't spoil the cache 36 self.cfg.caching_formats = [] # don't spoil the cache
37 self.initTheme() # usually request.run() does this, but we don't use it 37 self.initTheme() # usually request.run() does this, but we don't use it
38 38
39 def _setup_args_from_cgi_form(self): 39 def _setup_args_from_cgi_form(self):
40 """ Override to create cli form """ 40 """ Override to create cli form """