Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test for apt.update_sources_list #2792

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions uaclient/tests/test_apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
run_apt_update_command,
setup_apt_proxy,
update_esm_caches,
update_sources_list,
)
from uaclient.entitlements.base import UAEntitlement
from uaclient.entitlements.entitlement_status import ApplicationStatus
Expand Down Expand Up @@ -1453,3 +1454,36 @@ def test_get_alternative_versions_excluding_origin(self):
)
)
]


class TestUpdateSourcesList:
@mock.patch("uaclient.apt.os.path.join")
@mock.patch("apt_pkg.FileLock")
@mock.patch("uaclient.apt.AcquireProgress")
@mock.patch("apt_pkg.SourceList")
@mock.patch("apt_pkg.config")
@mock.patch("uaclient.apt.PreserveAptCfg")
def test_update_sources_list(
self,
m_preserve_apt_cfg,
m_apt_pkg_config,
m_apt_pkg_source_list,
m_acquire_progress,
_m_file_lock,
_m_join,
):
update_sources_list("/sources.list")
assert (
mock.call("Dir::Etc::sourcelist", "/sources.list")
in m_apt_pkg_config.set.call_args_list
)
assert (
[
mock.call(
m_acquire_progress.return_value,
m_apt_pkg_source_list.return_value,
0,
)
]
== m_preserve_apt_cfg.return_value.__enter__.return_value.update.call_args_list # noqa: E501
)
Loading