Skip to content

Commit b717d64

Browse files
committed
Remove charmstore from unit tests
1 parent 961cd26 commit b717d64

3 files changed

Lines changed: 13 additions & 155 deletions

File tree

tests/unit/test_bundle.py

Lines changed: 11 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -170,118 +170,6 @@ def test_dict_params_missing_data(self):
170170

171171
class 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

557435
class TestAddMachineChange(unittest.TestCase):
558436

tests/unit/test_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ def test_get_series():
118118
},
119119
},
120120
}
121-
assert model._get_series('cs:trusty/ubuntu', entity) == 'trusty'
121+
assert model._get_series('ch:trusty/ubuntu', entity) == 'trusty'
122122
assert model._get_series('xenial/ubuntu', entity) == 'xenial'
123123
assert model._get_series('~foo/xenial/ubuntu', entity) == 'xenial'
124124
assert model._get_series('~foo/ubuntu', entity) == 'xenial'
125125
assert model._get_series('ubuntu', entity) == 'xenial'
126-
assert model._get_series('cs:ubuntu', entity) == 'xenial'
126+
assert model._get_series('ch:ubuntu', entity) == 'xenial'
127127

128128

129129
class TestContextManager(asynctest.TestCase):

tests/unit/test_url.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,10 @@
44

55

66
class TestURLV1(unittest.TestCase):
7-
def test_parse_charmstore(self):
8-
u = URL.parse("cs:mysql")
9-
self.assertEqual(u, URL(Schema.CHARM_STORE, name="mysql"))
10-
117
def test_parse_local(self):
128
u = URL.parse("local:mysql")
139
self.assertEqual(u, URL(Schema.LOCAL, name="mysql"))
1410

15-
def test_parse_v1_user(self):
16-
u = URL.parse("cs:~fred/mysql")
17-
self.assertEqual(u, URL(Schema.CHARM_STORE, name="mysql", user="fred"))
18-
19-
def test_parse_v1_revision(self):
20-
u = URL.parse("cs:~fred/mysql-1")
21-
self.assertEqual(u, URL(Schema.CHARM_STORE, name="mysql", user="fred", revision=1))
22-
23-
def test_parse_v1_large_revision(self):
24-
u = URL.parse("cs:~fred/mysql-12345")
25-
self.assertEqual(u, URL(Schema.CHARM_STORE, name="mysql", user="fred", revision=12345))
26-
27-
def test_parse_v1_series(self):
28-
u = URL.parse("cs:~fred/bionic/mysql-1")
29-
self.assertEqual(u, URL(Schema.CHARM_STORE, name="mysql", user="fred", revision=1, series="bionic"))
30-
3111

3212
class TestURLV2(unittest.TestCase):
3313
def test_parse_charmhub(self):

0 commit comments

Comments
 (0)