mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
*: Use action_utils.run instead of subprocess.check_call
- This is to capture stdout and stderr and transmit that from privileged daemon back to the service to be displayed in HTML. Tests: - Unit tests and code checks pass. - Some of the modified actions work as expected. - systemd daemon-reload is performed during infinoted setup. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
1 parent
61ff15a04f
commit
80e6d940a4
9 files changed
+44
-44
No files matched your search
@@ -264,9 +264,8 @@ def test_services_disable(service_is_running, service_disable, service_enable):
|
||||
|
||||
|
||||
@patch('subprocess.run')
|
||||
@patch('subprocess.check_call')
|
||||
@patch('subprocess.check_output')
|
||||
def test_apt_hold_packages(check_output, check_call, run, tmp_path):
|
||||
def test_apt_hold_packages(check_output, run, tmp_path):
|
||||
"""Test that holding apt packages works."""
|
||||
hold_flag = tmp_path / 'flag'
|
||||
run.return_value.returncode = 0
|
||||
@@ -277,29 +276,28 @@ def test_apt_hold_packages(check_output, check_call, run, tmp_path):
|
||||
with distupgrade._apt_hold_packages():
|
||||
assert hold_flag.exists()
|
||||
assert hold_flag.stat().st_mode & 0o117 == 0
|
||||
expected_call = [call(['apt-mark', 'hold', 'freedombox'])]
|
||||
assert check_call.call_args_list == expected_call
|
||||
expected_calls = [
|
||||
call(['apt-mark', 'hold', 'freedombox'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
check=True),
|
||||
call(['apt-mark', 'hold', 'package1'], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, check=False),
|
||||
call(['apt-mark', 'hold', 'package2'], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, check=False)
|
||||
]
|
||||
assert run.call_args_list == expected_calls
|
||||
check_call.reset_mock()
|
||||
run.reset_mock()
|
||||
|
||||
expected_call = [
|
||||
call(['apt-mark', 'unhold', 'package1'], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, check=True),
|
||||
call(['apt-mark', 'unhold', 'package2'], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, check=True),
|
||||
call(['apt-mark', 'unhold', 'freedombox'],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
check=False)
|
||||
check=False),
|
||||
]
|
||||
assert run.call_args_list == expected_call
|
||||
expected_calls = [
|
||||
call(['apt-mark', 'unhold', 'package1']),
|
||||
call(['apt-mark', 'unhold', 'package2'])
|
||||
]
|
||||
assert check_call.call_args_list == expected_calls
|
||||
|
||||
|
||||
@patch('plinth.action_utils.debconf_set_selections')
|
||||
|
||||
Reference in new issue
Block a user