Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed May 3, 2024
1 parent fb4ba98 commit 27a5398
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cloudinit/distros/alpine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from cloudinit import distros, helpers, subp, util
from cloudinit.distros.parsers.hostname import HostnameConf
from cloudinit.settings import PER_INSTANCE, PER_ALWAYS
from cloudinit.settings import PER_ALWAYS, PER_INSTANCE

LOG = logging.getLogger(__name__)

Expand Down
29 changes: 15 additions & 14 deletions tests/unittests/config/test_apt_source_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def setup(self, mocker, tmpdir):

@staticmethod
def _add_apt_sources(cfg, cloud, gpg, **kwargs):
with mock.patch.object(cc_apt_configure, "update_packages"):
cc_apt_configure.add_apt_sources(cfg, cloud, gpg, **kwargs)
# with mock.patch.object(cloud.distro, "update_package_sources"):
cc_apt_configure.add_apt_sources(cfg, cloud, gpg, **kwargs)

@staticmethod
def _get_default_params():
Expand All @@ -89,7 +89,7 @@ def _apt_src_basic(self, filename, cfg, tmpdir, gpg):

self._add_apt_sources(
cfg,
cloud=None,
cloud=mock.Mock(),
gpg=gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand Down Expand Up @@ -185,7 +185,7 @@ def _apt_src_replacement(self, filename, cfg, tmpdir, gpg):
params = self._get_default_params()
self._add_apt_sources(
cfg,
cloud=None,
cloud=mock.Mock(),
gpg=gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand Down Expand Up @@ -261,10 +261,11 @@ def _apt_src_keyid(
"""
params = self._get_default_params()

cloud = get_cloud()
with mock.patch.object(cc_apt_configure, "add_apt_key") as mockobj:
self._add_apt_sources(
cfg,
cloud=None,
cloud=cloud,
gpg=gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand All @@ -274,9 +275,9 @@ def _apt_src_keyid(
calls = []
for key in cfg:
if is_hardened is not None:
calls.append(call(cfg[key], None, gpg, hardened=is_hardened))
calls.append(call(cfg[key], cloud, gpg, hardened=is_hardened))
else:
calls.append(call(cfg[key], None, gpg))
calls.append(call(cfg[key], cloud, gpg))

mockobj.assert_has_calls(calls, any_order=True)

Expand Down Expand Up @@ -389,7 +390,7 @@ def test_apt_v3_src_key(self, mocker, m_gpg):
mockobj = mocker.patch.object(cc_apt_configure, "apt_key")
self._add_apt_sources(
cfg,
cloud=None,
cloud=mock.Mock(),
gpg=m_gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand Down Expand Up @@ -427,7 +428,7 @@ def test_apt_v3_src_keyonly(self, mocker, m_gpg):
mockobj = mocker.patch.object(cc_apt_configure, "apt_key")
self._add_apt_sources(
cfg,
cloud=None,
cloud=mock.Mock(),
gpg=m_gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand Down Expand Up @@ -458,7 +459,7 @@ def test_apt_v3_src_keyidonly(self, m_gpg):
with mock.patch.object(cc_apt_configure, "apt_key") as mockobj:
self._add_apt_sources(
cfg,
cloud=None,
cloud=mock.Mock(),
gpg=m_gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand Down Expand Up @@ -494,7 +495,7 @@ def apt_src_keyid_real(self, cfg, expectedkey, gpg, is_hardened=None):
) as mockgetkey:
self._add_apt_sources(
cfg,
cloud=None,
cloud=mock.Mock(),
gpg=gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand Down Expand Up @@ -559,7 +560,7 @@ def test_apt_v3_src_keyid_keyserver(self, m_gpg):
with mock.patch.object(cc_apt_configure, "add_apt_key_raw") as mockadd:
self._add_apt_sources(
cfg,
cloud=None,
cloud=mock.Mock(),
gpg=m_gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand All @@ -584,7 +585,7 @@ def test_apt_v3_src_ppa(self, m_gpg):
with mock.patch("cloudinit.subp.subp") as mockobj:
self._add_apt_sources(
cfg,
cloud=None,
cloud=mock.Mock(),
gpg=m_gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand Down Expand Up @@ -614,7 +615,7 @@ def test_apt_v3_src_ppa_tri(self, m_gpg):
with mock.patch("cloudinit.subp.subp") as mockobj:
self._add_apt_sources(
cfg,
cloud=None,
cloud=mock.Mock(),
gpg=m_gpg,
template_params=params,
aa_repo_match=self.matcher,
Expand Down

0 comments on commit 27a5398

Please sign in to comment.