diff options
-rw-r--r-- | doc/examples/cloud-config.txt | 6 | ||||
-rw-r--r-- | tests/unittests/test_handler/test_handler_apt_configure_sources_list.py | 5 | ||||
-rw-r--r-- | tests/unittests/test_handler/test_handler_apt_source.py | 20 |
3 files changed, 21 insertions, 10 deletions
diff --git a/doc/examples/cloud-config.txt b/doc/examples/cloud-config.txt index 62b297bc..3cc9c055 100644 --- a/doc/examples/cloud-config.txt +++ b/doc/examples/cloud-config.txt @@ -125,11 +125,11 @@ add_apt_repo_match: '^[\w-]+:\w' # better merging between multiple input files than a list like: # cloud-config1 # sources: - s1: {'key': 'key1', 'source': 'source1'} +# s1: {'key': 'key1', 'source': 'source1'} # cloud-config2 # sources: - s2: {'key': 'key2'} - s1: {filename: 'foo'} +# s2: {'key': 'key2'} +# s1: {filename: 'foo'} # this would be merged to #sources: # s1: diff --git a/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py b/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py index 5d0417a2..5f1dd427 100644 --- a/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py +++ b/tests/unittests/test_handler/test_handler_apt_configure_sources_list.py @@ -103,8 +103,9 @@ class TestAptSourceConfigSourceList(t_help.FilesystemMockingTestCase): with mock.patch.object(templater, 'render_to_file') as mocktmpl: with mock.patch.object(os.path, 'isfile', return_value=True) as mockisfile: - cc_apt_configure.handle("notimportant", cfg, mycloud, - LOG, None) + with mock.patch.object(util, 'rename'): + cc_apt_configure.handle("notimportant", cfg, mycloud, + LOG, None) mockisfile.assert_any_call( ('/etc/cloud/templates/sources.list.%s.tmpl' % distro)) diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py index 4dbe69f0..fa28c916 100644 --- a/tests/unittests/test_handler/test_handler_apt_source.py +++ b/tests/unittests/test_handler/test_handler_apt_source.py @@ -43,6 +43,8 @@ class TestAptSourceConfig(TestCase): """TestAptSourceConfig Main Class to test apt_source configs """ + release = "fantastic" + def setUp(self): super(TestAptSourceConfig, self).setUp() self.tmp = tempfile.mkdtemp() @@ -55,8 +57,12 @@ class TestAptSourceConfig(TestCase): self.fallbackfn = os.path.join(self.tmp, "etc/apt/sources.list.d/", "cloud_config_sources.list") - @staticmethod - def _get_default_params(): + patcher = mock.patch("cloudinit.config.cc_apt_configure.get_release") + get_rel = patcher.start() + get_rel.return_value = self.release + self.addCleanup(patcher.stop) + + def _get_default_params(self): """get_default_params Get the most basic default mrror and release info to be used in tests """ @@ -438,7 +444,7 @@ class TestAptSourceConfig(TestCase): def test_apt_src_keyid_real(self): """test_apt_src_keyid_real Test specification of a keyid without source incl - up to addition of the key (nothing but add_key_raw mocked) + up to addition of the key (add_key_raw, getkeybyid mocked) """ keyid = "03683F77" params = self._get_default_params() @@ -446,7 +452,9 @@ class TestAptSourceConfig(TestCase): 'filename': self.aptlistfile} with mock.patch.object(cc_apt_configure, 'add_key_raw') as mockobj: - cc_apt_configure.add_sources([cfg], params) + with mock.patch.object(cc_apt_configure, 'getkeybyid') as gkbi: + gkbi.return_value = EXPECTEDKEY + cc_apt_configure.add_sources([cfg], params) mockobj.assert_called_with(EXPECTEDKEY) @@ -464,7 +472,9 @@ class TestAptSourceConfig(TestCase): 'filename': self.aptlistfile} with mock.patch.object(cc_apt_configure, 'add_key_raw') as mockobj: - cc_apt_configure.add_sources([cfg], params) + with mock.patch.object(cc_apt_configure, 'getkeybyid') as gkbi: + gkbi.return_value = EXPECTEDKEY + cc_apt_configure.add_sources([cfg], params) mockobj.assert_called_with(EXPECTEDKEY) |