Skip to content

Commit

Permalink
test: eliminate obsolete cases, add non-error case
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Jan 9, 2025
1 parent b0a6df8 commit 578b76b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 38 deletions.
4 changes: 1 addition & 3 deletions cloudinit/config/cc_ubuntu_autoinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from cloudinit import subp, util
from cloudinit.cloud import Cloud
from cloudinit.config import Config
from cloudinit.config.schema import (
MetaSchema,
)
from cloudinit.config.schema import MetaSchema
from cloudinit.settings import PER_ONCE

LOG = logging.getLogger(__name__)
Expand Down
37 changes: 2 additions & 35 deletions tests/unittests/config/test_cc_ubuntu_autoinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,6 @@
)


class TestvalidateConfigSchema:
@pytest.mark.parametrize(
"src_cfg,error_msg",
[
pytest.param(
{"autoinstall": 1},
"autoinstall: Expected dict type but found: int",
id="err_non_dict",
),
pytest.param(
{"autoinstall": {}},
"autoinstall: Missing required 'version' key",
id="err_require_version_key",
),
pytest.param(
{"autoinstall": {"version": "v1"}},
"autoinstall.version: Expected int type but found: str",
id="err_version_non_int",
),
],
)
def test_runtime_validation_errors(self, src_cfg, error_msg):
"""cloud-init raises errors at runtime on invalid autoinstall config"""
with pytest.raises(SchemaValidationError, match=error_msg):
cc_ubuntu_autoinstall.validate_config_schema(src_cfg)


@mock.patch(MODPATH + "util.wait_for_snap_seeded")
@mock.patch(MODPATH + "subp.subp")
class TestHandleAutoinstall:
Expand All @@ -73,14 +46,6 @@ class TestHandleAutoinstall:
@pytest.mark.parametrize(
"cfg,snap_list,subp_calls,logs,snap_wait_called",
[
pytest.param(
{},
SAMPLE_SNAP_LIST_OUTPUT,
[],
["Skipping module named name, no 'autoinstall' key"],
False,
id="skip_no_cfg",
),
pytest.param(
{"autoinstall": {"version": 1}},
SAMPLE_SNAP_LIST_OUTPUT,
Expand Down Expand Up @@ -149,6 +114,8 @@ class TestAutoInstallSchema:
{"autoinstall": {}},
"autoinstall: 'version' is a required property",
),
({"autoinstall": {"version": 1}}, None),
({"autoinstall": {"version": "v1"}}, "is not of type 'integer'"),
),
)
@skipUnlessJsonSchema()
Expand Down

0 comments on commit 578b76b

Please sign in to comment.