Skip to content

Commit 004dc9c

Browse files
committed
Update unit tests and fix linter errors
1 parent 697f99e commit 004dc9c

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

capi_janitor/openstack/operator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ async def try_delete(logger, resource, instances, **kwargs):
154154
return check_required
155155

156156

157-
async def purge_openstack_resources(
157+
async def purge_openstack_resources( # noqa: C901
158158
logger,
159159
clouds,
160160
cloud_name,
@@ -193,7 +193,7 @@ async def purge_openstack_resources(
193193
logger,
194194
loadbalancers,
195195
lbs_for_cluster(loadbalancers, name),
196-
cascade="true"
196+
cascade="true",
197197
)
198198
logger.info("deleted load balancers for LoadBalancer services")
199199

@@ -441,8 +441,8 @@ async def _on_openstackcluster_event_impl(
441441
# Default to false since this is default CAPO behaviour if
442442
# ApiServerLoadBalancer field is omitted from OpenStackClusterSpec
443443
# https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/57ae27ee114bda3606d92163397697b640272673/api/v1beta1/openstackcluster_types.go#L99-L101
444-
spec.get('apiServerLoadBalancer', {}).get('enabled', False) and
445-
status.get('apiServerLoadBalancer', {}).get('id', '') != ''
444+
spec.get("apiServerLoadBalancer", {}).get("enabled", False)
445+
and status.get("apiServerLoadBalancer", {}).get("id", "") != ""
446446
)
447447

448448
await purge_openstack_resources(

capi_janitor/tests/openstack/test_operator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ async def test_on_openstackcluster_event_adds_finalizers(
232232
meta={},
233233
labels={},
234234
spec={},
235+
status={},
235236
logger=logger,
236237
body={},
237238
)
@@ -258,6 +259,7 @@ async def test_on_openstackcluster_event_skip_no_finalizers(
258259
meta={"deletionTimestamp": "2023-10-01T00:00:00Z"},
259260
labels={},
260261
spec={},
262+
status={},
261263
logger=logger,
262264
body={},
263265
)
@@ -319,6 +321,7 @@ async def test_on_openstackcluster_event_calls_purge(
319321
},
320322
labels={},
321323
spec={"identityRef": {"name": "appcred42"}},
324+
status={},
322325
logger=logger,
323326
body={},
324327
)
@@ -330,6 +333,7 @@ async def test_on_openstackcluster_event_calls_purge(
330333
None,
331334
"mycluster",
332335
True,
336+
False,
333337
True,
334338
)
335339
mock_delete_secret.assert_awaited_once_with("appcred42", "namespace1")
@@ -383,6 +387,7 @@ async def test_purge_openstack_resources_raises(self, mock_from_clouds):
383387
None,
384388
"mycluster",
385389
True,
390+
True,
386391
False,
387392
)
388393
self.assertEqual(

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ commands = stestr run {posargs}
2020
[testenv:autofix]
2121
commands =
2222
ruff format {tox_root}
23-
codespell {tox_root} -w
23+
codespell {tox_root} -w --skip venv
2424
ruff check {tox_root} --fix
2525

2626
[testenv:black]
@@ -29,7 +29,7 @@ commands =
2929
commands = black {tox_root} --check
3030

3131
[testenv:codespell]
32-
commands = codespell {posargs}
32+
commands = codespell --skip ./venv {posargs}
3333

3434
[testenv:ruff]
3535
description = Run Ruff checks

0 commit comments

Comments
 (0)