@@ -61,29 +61,12 @@ def _import_migwsgi():
61
61
migwsgi = _import_migwsgi ()
62
62
63
63
64
- def _assert_local_config ():
65
- try :
66
- link_stat = os .lstat (_TEST_CONF_SYMLINK )
67
- assert stat .S_ISLNK (link_stat .st_mode )
68
- configdir_stat = os .stat (_TEST_CONF_DIR )
69
- assert stat .S_ISDIR (configdir_stat .st_mode )
70
- config = ConfigParser ()
71
- config .read ([_TEST_CONF_FILE ])
72
- return config
73
- except Exception as exc :
74
- raise AssertionError ('local configuration invalid or missing: %s' % (str (exc ),))
75
-
76
-
77
- def _assert_local_config_global_values (config ):
78
- config_global_values = dict (config .items ('GLOBAL' ))
79
-
80
- for path in ('mig_path' , 'certs_path' , 'state_path' ):
81
- path_value = config_global_values .get (path )
64
+ def _assert_local_config_global_values (configuration ):
65
+ for config_key in ('mig_path' , 'certs_path' , 'state_path' ):
66
+ path_value = getattr (configuration , config_key )
82
67
if not is_path_within (path_value , start = _LOCAL_MIG_BASE ):
83
68
raise AssertionError ('local config contains bad path: %s=%s' % (path , path_value ))
84
69
85
- return config_global_values
86
-
87
70
88
71
def _is_return_value (return_value ):
89
72
defined_return_values = returnvalues .__dict__ .values ()
@@ -197,12 +180,14 @@ def was_called(fake):
197
180
self .assertTrue (was_called (self .instrumented_format_output ), "no output generated" )
198
181
self .assertTrue (was_called (self .instrumented_retrieve_handler ), "no output generated" )
199
182
183
+ def _provide_configuration (self ):
184
+ return 'testconfig'
185
+
200
186
def before_each (self ):
201
- config = _assert_local_config ()
202
- config_global_values = _assert_local_config_global_values (config )
187
+ _assert_local_config_global_values (self .configuration )
203
188
204
189
# generic WSGI setup
205
- self .fake_wsgi_environ = create_wsgi_environ (_TEST_CONF_FILE , wsgi_variables = dict (
190
+ self .fake_wsgi_environ = create_wsgi_environ (self . configuration , wsgi_variables = dict (
206
191
http_host = 'localhost' ,
207
192
path_info = '/' ,
208
193
))
@@ -212,11 +197,9 @@ def before_each(self):
212
197
self .instrumented_format_output = create_instrumented_format_output ()
213
198
self .instrumented_retrieve_handler = create_instrumented_retrieve_handler ()
214
199
215
- self .application_args = (self .fake_wsgi_environ , self .fake_start_response ,)
200
+ self .application_args = (self .configuration , self . fake_wsgi_environ , self .fake_start_response ,)
216
201
self .application_kwargs = dict (
217
202
_wrap_wsgi_errors = noop ,
218
- _config_file = _TEST_CONF_FILE ,
219
- _skip_log = True ,
220
203
_format_output = self .instrumented_format_output ,
221
204
_retrieve_handler = self .instrumented_retrieve_handler ,
222
205
_set_environ = noop ,
0 commit comments