← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~smoser/cloud-init:fix/fix-schematests-without-json-schema into cloud-init:master

 

Scott Moser has proposed merging ~smoser/cloud-init:fix/fix-schematests-without-json-schema into cloud-init:master.

Commit message:
tests: Fix newly added schema unit tests to skip if no jsonschema.

The recently added snap and ubuntu_advantage modules had unit tests
that exercised jsonschema.  Those throw error if jsonschema is
not present.  Fix to skip in that scenario.


Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/341997

related related https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/341995
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:fix/fix-schematests-without-json-schema into cloud-init:master.
diff --git a/cloudinit/config/tests/test_snap.py b/cloudinit/config/tests/test_snap.py
index 988e7f7..c55ead0 100644
--- a/cloudinit/config/tests/test_snap.py
+++ b/cloudinit/config/tests/test_snap.py
@@ -8,7 +8,8 @@ from cloudinit.config.cc_snap import (
     run_commands, schema)
 from cloudinit.config.schema import validate_cloudconfig_schema
 from cloudinit import util
-from cloudinit.tests.helpers import CiTestCase, mock, wrap_and_call
+from cloudinit.tests.helpers import (
+    CiTestCase, mock, wrap_and_call, skipUnlessJsonSchema)
 
 
 SYSTEM_USER_ASSERTION = """\
@@ -243,10 +244,12 @@ class TestRunCommands(CiTestCase):
         self.assertEqual('MOM\nHI\n', util.load_file(outfile))
 
 
+@skipUnlessJsonSchema()
 class TestSchema(CiTestCase):
 
     with_logs = True
 
+    @skipUnlessJsonSchema()
     def test_schema_warns_on_snap_not_as_dict(self):
         """If the snap configuration is not a dict, emit a warning."""
         validate_cloudconfig_schema({'snap': 'wrong type'}, schema)
@@ -418,6 +421,7 @@ class TestHandle(CiTestCase):
             util.load_file(compare_file), util.load_file(assert_file))
 
     @mock.patch('cloudinit.config.cc_snap.util.subp')
+    @skipUnlessJsonSchema()
     def test_handle_validates_schema(self, m_subp):
         """Any provided configuration is runs validate_cloudconfig_schema."""
         assert_file = self.tmp_path('snapd.assertions', dir=self.tmp)
diff --git a/cloudinit/config/tests/test_ubuntu_advantage.py b/cloudinit/config/tests/test_ubuntu_advantage.py
index 0eeadd4..f2a59fa 100644
--- a/cloudinit/config/tests/test_ubuntu_advantage.py
+++ b/cloudinit/config/tests/test_ubuntu_advantage.py
@@ -7,7 +7,7 @@ from cloudinit.config.cc_ubuntu_advantage import (
     handle, maybe_install_ua_tools, run_commands, schema)
 from cloudinit.config.schema import validate_cloudconfig_schema
 from cloudinit import util
-from cloudinit.tests.helpers import CiTestCase, mock
+from cloudinit.tests.helpers import CiTestCase, mock, skipUnlessJsonSchema
 
 
 # Module path used in mocks
@@ -104,6 +104,7 @@ class TestRunCommands(CiTestCase):
         self.assertEqual('MOM\nHI\n', util.load_file(outfile))
 
 
+@skipUnlessJsonSchema()
 class TestSchema(CiTestCase):
 
     with_logs = True

References