From 0c2f1ea29abc88957d21f56d432649989a8e4dfd Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 23 Mar 2018 15:16:55 -0400 Subject: 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. --- cloudinit/config/tests/test_snap.py | 5 ++++- cloudinit/config/tests/test_ubuntu_advantage.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'cloudinit/config/tests') diff --git a/cloudinit/config/tests/test_snap.py b/cloudinit/config/tests/test_snap.py index 988e7f7c..c5b4a9de 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,6 +244,7 @@ class TestRunCommands(CiTestCase): self.assertEqual('MOM\nHI\n', util.load_file(outfile)) +@skipUnlessJsonSchema() class TestSchema(CiTestCase): with_logs = True @@ -418,6 +420,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 0eeadd43..f2a59faf 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 -- cgit v1.2.3