diff options
author | Scott Moser <smoser@ubuntu.com> | 2018-03-09 04:22:24 +0100 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2018-03-09 04:22:24 +0100 |
commit | b7a790246e52520b47a467fe89b81199b9cf03f6 (patch) | |
tree | f39c712b38233faad1896ef6de50b9f7a3a6bb6d /tests/unittests/test_handler | |
parent | 1e2e810f3f7cb6a163a0229ac37037e8c6744d72 (diff) | |
download | vyos-cloud-init-b7a790246e52520b47a467fe89b81199b9cf03f6.tar.gz vyos-cloud-init-b7a790246e52520b47a467fe89b81199b9cf03f6.zip |
shellify: raise TypeError on bad input.
This makes 2 changes to shellify's behavior:
a.) raise a TypeError rather than a RuntimeError.
b.) raise a TypeError if input is not a list or tuple.
Diffstat (limited to 'tests/unittests/test_handler')
-rw-r--r-- | tests/unittests/test_handler/test_handler_bootcmd.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/unittests/test_handler/test_handler_bootcmd.py b/tests/unittests/test_handler/test_handler_bootcmd.py index dbf43e0d..09d4c681 100644 --- a/tests/unittests/test_handler/test_handler_bootcmd.py +++ b/tests/unittests/test_handler/test_handler_bootcmd.py @@ -69,7 +69,7 @@ class TestBootcmd(CiTestCase): cc_bootcmd.handle('cc_bootcmd', invalid_config, cc, LOG, []) self.assertIn('Failed to shellify bootcmd', self.logs.getvalue()) self.assertEqual( - "'int' object is not iterable", + "Input to shellify was type 'int'. Expected list or tuple.", str(context_manager.exception)) @skipIf(_missing_jsonschema_dep, "No python-jsonschema dependency") @@ -98,7 +98,7 @@ class TestBootcmd(CiTestCase): invalid_config = { 'bootcmd': ['ls /', 20, ['wget', 'http://stuff/blah'], {'a': 'n'}]} cc = self._get_cloud('ubuntu') - with self.assertRaises(RuntimeError) as context_manager: + with self.assertRaises(TypeError) as context_manager: cc_bootcmd.handle('cc_bootcmd', invalid_config, cc, LOG, []) expected_warnings = [ 'bootcmd.1: 20 is not valid under any of the given schemas', @@ -110,7 +110,8 @@ class TestBootcmd(CiTestCase): self.assertIn(warning, logs) self.assertIn('Failed to shellify', logs) self.assertEqual( - 'Unable to shellify type int which is not a list or string', + ("Unable to shellify type 'int'. Expected list, string, tuple. " + "Got: 20"), str(context_manager.exception)) def test_handler_creates_and_runs_bootcmd_script_with_instance_id(self): |