@@ -170,118 +170,6 @@ def test_dict_params_missing_data(self):
170170
171171class TestAddApplicationChangeRun :
172172
173- @pytest .mark .asyncio
174- async def test_run_with_charmstore_charm (self , event_loop ):
175- change = AddApplicationChange (1 , [], params = {"charm" : "cs:charm" ,
176- "series" : "series" ,
177- "application" : "application" ,
178- "options" : "options" ,
179- "constraints" : "constraints" ,
180- "storage" : "storage" ,
181- "endpoint-bindings" : "endpoint_bindings" ,
182- "resources" : "resources" ,
183- "devices" : "devices" ,
184- "num-units" : "num_units" ,
185- "channel" : "channel" })
186-
187- model = mock .Mock ()
188- model ._deploy = base .AsyncMock (return_value = None )
189- model ._add_store_resources = base .AsyncMock (return_value = ["resource1" ])
190- model .applications = {}
191-
192- context = mock .Mock ()
193- context .resolve .return_value = "cs:charm1"
194- context .origins = {"cs:charm1" : {"channel/stable" : {}}}
195- context .trusted = False
196- context .model = model
197-
198- result = await change .run (context )
199- assert result == "application"
200-
201- model ._add_store_resources .assert_called_once ()
202- model ._add_store_resources .assert_called_with ("application" ,
203- "cs:charm1" ,
204- overrides = "resources" )
205-
206- model ._deploy .assert_called_once ()
207- model ._deploy .assert_called_with (charm_url = "cs:charm1" ,
208- application = "application" ,
209- series = "series" ,
210- config = "options" ,
211- constraints = "constraints" ,
212- endpoint_bindings = "endpoint_bindings" ,
213- resources = ["resource1" ],
214- storage = "storage" ,
215- devices = "devices" ,
216- channel = "channel" ,
217- charm_origin = ANY ,
218- num_units = "num_units" )
219-
220- # confirm that it's idempotent
221- model .applications = {"application" : None }
222- result = await change .run (context )
223- assert result == "application"
224- model ._add_store_resources .assert_called_once ()
225- model ._deploy .assert_called_once ()
226-
227- @pytest .mark .asyncio
228- async def test_run_with_charmstore_charm_no_channel (self , event_loop ):
229- """Test to verify if when the given channel is None, the channel defaults to "stable", which
230- is the default channel value for the Chart Store
231- """
232-
233- change = AddApplicationChange (1 , [], params = {"charm" : "cs:charm" ,
234- "series" : "series" ,
235- "application" : "application" ,
236- "options" : "options" ,
237- "constraints" : "constraints" ,
238- "storage" : "storage" ,
239- "endpoint-bindings" : "endpoint_bindings" ,
240- "resources" : "resources" ,
241- "devices" : "devices" ,
242- "num-units" : "num_units" ,
243- "channel" : None })
244-
245- model = mock .Mock ()
246- model ._deploy = base .AsyncMock (return_value = None )
247- model ._add_store_resources = base .AsyncMock (return_value = ["resource1" ])
248- model .applications = {}
249-
250- context = mock .Mock ()
251- context .resolve .return_value = "cs:charm1"
252- context .origins = {"cs:charm1" : {"stable" : {}}}
253- context .trusted = False
254- context .model = model
255-
256- result = await change .run (context )
257- assert result == "application"
258-
259- model ._add_store_resources .assert_called_once ()
260- model ._add_store_resources .assert_called_with ("application" ,
261- "cs:charm1" ,
262- overrides = "resources" )
263-
264- model ._deploy .assert_called_once ()
265- model ._deploy .assert_called_with (charm_url = "cs:charm1" ,
266- application = "application" ,
267- series = "series" ,
268- config = "options" ,
269- constraints = "constraints" ,
270- endpoint_bindings = "endpoint_bindings" ,
271- resources = ["resource1" ],
272- storage = "storage" ,
273- devices = "devices" ,
274- channel = "stable" ,
275- charm_origin = ANY ,
276- num_units = "num_units" )
277-
278- # confirm that it's idempotent
279- model .applications = {"application" : None }
280- result = await change .run (context )
281- assert result == "application"
282- model ._add_store_resources .assert_called_once ()
283- model ._deploy .assert_called_once ()
284-
285173 @pytest .mark .asyncio
286174 async def test_run_with_charmhub_charm (self , event_loop ):
287175 change = AddApplicationChange (1 , [], params = {"charm" : "charm" ,
@@ -417,7 +305,7 @@ async def test_run_local(self, event_loop):
417305
418306 @pytest .mark .asyncio
419307 async def test_run_no_series (self , event_loop ):
420- change = AddApplicationChange (1 , [], params = {"charm" : "cs :charm1" ,
308+ change = AddApplicationChange (1 , [], params = {"charm" : "ch :charm1" ,
421309 "series" : "" ,
422310 "application" : "application" ,
423311 "options" : "options" ,
@@ -431,25 +319,22 @@ async def test_run_no_series(self, event_loop):
431319
432320 model = mock .Mock ()
433321 model ._deploy = base .AsyncMock (return_value = None )
434- model ._add_store_resources = base .AsyncMock (return_value = ["resource1" ])
322+ model ._add_charmhub_resources = base .AsyncMock (return_value = ["resource1" ])
435323 model .applications = {}
436324
437325 context = mock .Mock ()
438- context .resolve .return_value = "cs :charm1"
326+ context .resolve .return_value = "ch :charm1"
439327 context .trusted = False
440328 context .model = model
441329 context .bundle = {"bundle" : "kubernetes" }
442330
443331 result = await change .run (context )
444332 assert result == "application"
445333
446- model ._add_store_resources .assert_called_once ()
447- model ._add_store_resources .assert_called_with ("application" ,
448- "cs:charm1" ,
449- overrides = "resources" )
334+ model ._add_charmhub_resources .assert_called_once ()
450335
451336 model ._deploy .assert_called_once ()
452- model ._deploy .assert_called_with (charm_url = "cs :charm1" ,
337+ model ._deploy .assert_called_with (charm_url = "ch :charm1" ,
453338 application = "application" ,
454339 series = None ,
455340 config = "options" ,
@@ -466,7 +351,7 @@ async def test_run_no_series(self, event_loop):
466351 model .applications = {"application" : None }
467352 result = await change .run (context )
468353 assert result == "application"
469- model ._add_store_resources .assert_called_once ()
354+ model ._add_charmhub_resources .assert_called_once ()
470355 model ._deploy .assert_called_once ()
471356
472357
@@ -523,36 +408,29 @@ class TestAddCharmChangeRun:
523408
524409 @pytest .mark .asyncio
525410 async def test_run (self , event_loop ):
526- change = AddCharmChange (1 , [], params = {"charm" : "cs :charm" ,
411+ change = AddCharmChange (1 , [], params = {"charm" : "ch :charm" ,
527412 "series" : "series" ,
528413 "channel" : "channel" })
529414
530- charmstore = mock .Mock ()
531- charmstore .entityId = base .AsyncMock (return_value = "entity_id" )
532415
533416 charms_facade = mock .Mock ()
534417 charms_facade .AddCharm = base .AsyncMock (return_value = None )
535418
536419 model = mock .Mock ()
537420 model ._add_charm = base .AsyncMock (return_value = None )
421+ model ._resolve_architecture = base .AsyncMock (return_value = None )
422+ model ._resolve_charm = base .AsyncMock (return_value = ("entity_id" ,
423+ None , None ))
538424
539425 context = mock .Mock ()
540- context . charmstore = charmstore
426+
541427 context .charms_facade = charms_facade
542428 context .origins = {}
543429 context .model = model
544430
545431 result = await change .run (context )
546432 assert result == "entity_id"
547433
548- charmstore .entityId .assert_called_once ()
549- charmstore .entityId .assert_called_with ("cs:charm" , channel = "channel" )
550-
551- charms_facade .AddCharm .assert_called_once ()
552- charms_facade .AddCharm .assert_called_with (channel = "channel" ,
553- url = "entity_id" ,
554- force = False )
555-
556434
557435class TestAddMachineChange (unittest .TestCase ):
558436
0 commit comments