-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_install_suse.py
51 lines (40 loc) · 1.43 KB
/
test_install_suse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Tests for install.py for SUSE based Linux distributions
"""
import os
import shutil
from unittest import mock
import pytest
from install import Cmd, CmdError, RemoteFileNotFoundError
pytestmark = pytest.mark.skipif(
not pytest.helpers.helper_is_suse(),
reason="Tests for openSUSE/SUSE"
)
def test_rpm_download_raise_not_found_error(sys_rpm):
with mock.patch.object(Cmd, 'sh_e') as mock_sh_e:
ce = CmdError('test.')
ce.stderr = 'Package \'dummy\' not found.\n'
mock_sh_e.side_effect = ce
with pytest.raises(RemoteFileNotFoundError) as exc:
sys_rpm.download('dummy')
assert mock_sh_e.called
assert str(exc.value) == 'Package dummy not found on remote'
def test_rpm_extract_is_ok(sys_rpm, rpm_files, monkeypatch):
# mocking arch object for multi arch test cases.
sys_rpm.arch = 'x86_64'
with pytest.helpers.work_dir():
for rpm_file in rpm_files:
shutil.copy(rpm_file, '.')
sys_rpm.extract('rpm-build-libs')
files = os.listdir('./usr/lib64')
files.sort()
assert files == [
'librpmbuild.so.7',
'librpmbuild.so.7.0.1',
'librpmsign.so.7',
'librpmsign.so.7.0.1',
]
@pytest.mark.network
def test_app_verify_system_status_is_ok_on_sys_rpm_and_missing_pkgs(app):
app.linux.rpm.is_system_rpm = mock.MagicMock(return_value=True)
app.linux.verify_system_status()