@@ -136,23 +136,24 @@ def test_load_config_local_app(self):
136136 'general' : {'a' : 'b' , 'key2' : 'val2' },
137137 'some-app' : {'key1' : 'val1' }
138138 }
139- conf = Config ('some-app' , answers = initial_config )
139+ conf = Config (answers = initial_config )
140140
141141 nc = NuleculeComponent ('some-app' , 'some/path' ,
142142 params = params , config = conf )
143143 nc .load_config ()
144144 runtime_answers = nc .config .runtime_answers ()
145145 self .assertEqual (runtime_answers , {
146- 'general' : {'a' : 'b' , 'key2' : 'val2' , 'provider' : 'kubernetes' , 'namespace' : 'default' },
147- 'some-app' : {'key1' : 'val1' , 'key2' : 'val2' }
146+ 'general' : {
147+ 'a' : 'b' ,
148+ 'key2' : 'val2' ,
149+ 'provider' : 'kubernetes' ,
150+ 'namespace' : 'default'
151+ },
152+ 'some-app' : {'key1' : 'val1' }
148153 })
149154
150155 def test_load_config_external_app (self ):
151156 """Test load config for external app"""
152- mock_nulecule = mock .Mock (
153- name = 'nulecule' ,
154- spec = Nulecule ('some-id' , '0.0.2' , {}, [], 'some/path' )
155- )
156157 params = [
157158 {'name' : 'key1' , 'description' : 'key1' },
158159 {'name' : 'key2' , 'description' : 'key2' }
@@ -161,17 +162,19 @@ def test_load_config_external_app(self):
161162 'general' : {'a' : 'b' , 'key2' : 'val2' },
162163 'some-app' : {'key1' : 'val1' }
163164 }
164- config = Config ('some-app' , answers = initial_config )
165+ config = Config (answers = initial_config )
166+ mock_nulecule = mock .Mock (
167+ name = 'nulecule' ,
168+ spec = Nulecule ('some-id' , '0.0.2' , config , [], 'some/path' )
169+ )
165170
166171 nc = NuleculeComponent ('some-app' , 'some/path' , params = params )
167172 nc ._app = mock_nulecule
168- nc .load_config (config = config )
173+ nc .config = config
174+ nc .load_config ()
169175
170176 mock_nulecule .load_config .assert_called_once_with (
171- config = Config ('some-app' , answers = initial_config , data = {
172- 'general' : {},
173- 'some-app' : {'key1' : 'val1' , 'key2' : 'val2' }
174- }), ask = False , skip_asking = False )
177+ config = config , ask = False , skip_asking = False )
175178
176179
177180class TestNuleculeComponentLoadExternalApplication (unittest .TestCase ):
@@ -260,7 +263,7 @@ def test_render_for_local_app_with_missing_artifacts_for_provider(self):
260263 dryrun = False
261264
262265 nc = NuleculeComponent (name = 'some-app' , basepath = 'some/path' )
263- nc .config = {}
266+ nc .config = Config ()
264267 nc .artifacts = {'x' : ['some-artifact' ]}
265268
266269 self .assertRaises (NuleculeException , nc .render , provider_key , dryrun )
@@ -276,37 +279,44 @@ def test_render_for_local_app_with_missing_artifacts_from_nulecule(self):
276279 with self .assertRaises (NuleculeException ):
277280 nc .render ()
278281
279- @mock .patch ('atomicapp.nulecule.base.NuleculeComponent.get_context' )
280282 @mock .patch ('atomicapp.nulecule.base.NuleculeComponent.'
281283 'get_artifact_paths_for_provider' )
282284 @mock .patch ('atomicapp.nulecule.base.NuleculeComponent.render_artifact' )
283285 def test_render_for_local_app_with_artifacts_for_provider (
284- self , mock_render_artifact , mock_get_artifact_paths_for_provider ,
285- mock_get_context ):
286+ self , mock_render_artifact , mock_get_artifact_paths_for_provider ):
286287 """Test rendering artifacts for a local Nulecule component"""
287288 provider_key = 'some-provider'
288289 dryrun = False
289290 expected_rendered_artifacts = [
290291 'some/path/.artifact1' , 'some/path/.artifact2' ]
291- context = {'a' : 'b' }
292292 mock_get_artifact_paths_for_provider .return_value = [
293293 'some/path/artifact1' , 'some/path/artifact2' ]
294294 mock_render_artifact .side_effect = lambda path , context , provider : path .replace ('artifact' , '.artifact' )
295- mock_get_context .return_value = context
295+ # mock_get_context.return_value = context
296296
297297 nc = NuleculeComponent (name = 'some-app' , basepath = 'some/path' )
298- nc .config = {'general' : {'key1' : 'val1' }, 'some-provider' : {'a' : 'b' }}
298+ nc .config = Config (answers = {
299+ 'general' : {'key1' : 'val1' },
300+ 'some-provider' : {'a' : 'b' }
301+ })
299302 nc .artifacts = {
300303 'some-provider' : ['artifact1' , 'artifact2' ],
301304 'x' : ['foo' ]
302305 }
303306 nc .render (provider_key , dryrun )
304307
308+ expected_context = {
309+ 'key1' : 'val1' ,
310+ 'namespace' : 'default' ,
311+ 'provider' : 'kubernetes'
312+ }
305313 mock_get_artifact_paths_for_provider .assert_called_once_with (
306314 provider_key )
307- mock_render_artifact .assert_any_call ('some/path/artifact1' , context ,
315+ mock_render_artifact .assert_any_call ('some/path/artifact1' ,
316+ expected_context ,
308317 'some-provider' )
309- mock_render_artifact .assert_any_call ('some/path/artifact2' , context ,
318+ mock_render_artifact .assert_any_call ('some/path/artifact2' ,
319+ expected_context ,
310320 'some-provider' )
311321 mock_get_artifact_paths_for_provider .assert_called_once_with (
312322 provider_key )
0 commit comments