diff options
author | Daniel Watkins <daniel.watkins@canonical.com> | 2015-03-25 15:54:19 +0000 |
---|---|---|
committer | Daniel Watkins <daniel.watkins@canonical.com> | 2015-03-25 15:54:19 +0000 |
commit | d52feae7ad38670964edebb0eea5db2c8c80f760 (patch) | |
tree | 103bb23c3dbe8f71486406daf4438a37048b94d7 /tests/unittests/test_datasource | |
parent | 1828ac3fa151ec7ff761b34305ed5fb85a9020d1 (diff) | |
download | vyos-cloud-init-d52feae7ad38670964edebb0eea5db2c8c80f760.tar.gz vyos-cloud-init-d52feae7ad38670964edebb0eea5db2c8c80f760.zip |
Ensure that the serial console is always closed.
Diffstat (limited to 'tests/unittests/test_datasource')
-rw-r--r-- | tests/unittests/test_datasource/test_smartos.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_smartos.py b/tests/unittests/test_datasource/test_smartos.py index 39991cc2..28b41eaf 100644 --- a/tests/unittests/test_datasource/test_smartos.py +++ b/tests/unittests/test_datasource/test_smartos.py @@ -409,6 +409,18 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase): self.assertEqual(dsrc.device_name_to_device('FOO'), mydscfg['disk_aliases']['FOO']) + @mock.patch('cloudinit.sources.DataSourceSmartOS.JoyentMetadataClient') + @mock.patch('cloudinit.sources.DataSourceSmartOS.get_serial') + def test_serial_console_closed_on_error(self, get_serial, metadata_client): + class OurException(Exception): + pass + metadata_client.side_effect = OurException + try: + DataSourceSmartOS.query_data('noun', 'device', 0) + except OurException: + pass + self.assertEqual(1, get_serial.return_value.close.call_count) + def apply_patches(patches): ret = [] |