Skip to content

Commit c53eb98

Browse files
test: update bundle unit tests with storage constraint parsing
1 parent 1bfbb4c commit c53eb98

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

tests/unit/test_bundle.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
SetAnnotationsChange,
2424
)
2525
from juju import charmhub
26+
from juju import constraints
2627
from juju.client import client
2728
from toposort import CircularDependencyError
2829

@@ -123,12 +124,14 @@ def test_dict_params_missing_data(self):
123124
class TestAddApplicationChangeRun:
124125

125126
async def test_run_with_charmhub_charm(self):
127+
storage_label = "some-label"
128+
storage_constraint = "ebs,100G,1"
126129
change = AddApplicationChange(1, [], params={"charm": "charm",
127130
"series": "series",
128131
"application": "application",
129132
"options": "options",
130133
"constraints": "constraints",
131-
"storage": "storage",
134+
"storage": {storage_label: storage_constraint},
132135
"endpoint-bindings": "endpoint_bindings",
133136
"resources": "resources",
134137
"devices": "devices",
@@ -160,7 +163,7 @@ async def test_run_with_charmhub_charm(self):
160163
constraints="constraints",
161164
endpoint_bindings="endpoint_bindings",
162165
resources=["resource1"],
163-
storage="storage",
166+
storage={storage_label: constraints.parse_storage_constraint(storage_constraint)},
164167
devices="devices",
165168
channel="channel",
166169
charm_origin=ANY,
@@ -170,12 +173,14 @@ async def test_run_with_charmhub_charm_no_channel(self):
170173
"""Test to verify if when the given channel is None, the channel defaults to "local/stable", which
171174
is the default channel value for the Charm Hub
172175
"""
176+
storage_label = "some-label"
177+
storage_constraint = "ebs,100G,1"
173178
change = AddApplicationChange(1, [], params={"charm": "charm",
174179
"series": "series",
175180
"application": "application",
176181
"options": "options",
177182
"constraints": "constraints",
178-
"storage": "storage",
183+
"storage": {storage_label: storage_constraint},
179184
"endpoint-bindings": "endpoint_bindings",
180185
"resources": "resources",
181186
"devices": "devices",
@@ -208,19 +213,21 @@ async def test_run_with_charmhub_charm_no_channel(self):
208213
constraints="constraints",
209214
endpoint_bindings="endpoint_bindings",
210215
resources=["resource1"],
211-
storage="storage",
216+
storage={storage_label: constraints.parse_storage_constraint(storage_constraint)},
212217
devices="devices",
213218
channel="latest/stable",
214219
charm_origin=ANY,
215220
num_units="num_units")
216221

217222
async def test_run_local(self):
223+
storage_label = "some-label"
224+
storage_constraint = "ebs,100G,1"
218225
change = AddApplicationChange(1, [], params={"charm": "local:charm",
219226
"series": "series",
220227
"application": "application",
221228
"options": "options",
222229
"constraints": "constraints",
223-
"storage": "storage",
230+
"storage": {storage_label: storage_constraint},
224231
"endpoint-bindings": "endpoint_bindings",
225232
"devices": "devices",
226233
"num-units": "num_units"})
@@ -246,19 +253,21 @@ async def test_run_local(self):
246253
constraints="constraints",
247254
endpoint_bindings="endpoint_bindings",
248255
resources={},
249-
storage="storage",
256+
storage={storage_label: constraints.parse_storage_constraint(storage_constraint)},
250257
devices="devices",
251258
num_units="num_units",
252259
channel="",
253260
charm_origin=ANY)
254261

255262
async def test_run_no_series(self):
263+
storage_label = "some-label"
264+
storage_constraint = "ebs,100G,1"
256265
change = AddApplicationChange(1, [], params={"charm": "ch:charm1",
257266
"series": "",
258267
"application": "application",
259268
"options": "options",
260269
"constraints": "constraints",
261-
"storage": "storage",
270+
"storage": {storage_label: storage_constraint},
262271
"endpoint-bindings": "endpoint_bindings",
263272
"resources": "resources",
264273
"devices": "devices",
@@ -289,7 +298,7 @@ async def test_run_no_series(self):
289298
constraints="constraints",
290299
endpoint_bindings="endpoint_bindings",
291300
resources=["resource1"],
292-
storage="storage",
301+
storage={storage_label: constraints.parse_storage_constraint(storage_constraint)},
293302
devices="devices",
294303
channel="channel",
295304
charm_origin=ANY,

0 commit comments

Comments
 (0)