diff --git a/repos/system_upgrade/common/actors/checkfirstpartitionoffset/tests/test_check_first_partition_offset.py b/repos/system_upgrade/common/actors/checkfirstpartitionoffset/tests/test_check_first_partition_offset.py index 3f379e049a..40f7c3f7dc 100644 --- a/repos/system_upgrade/common/actors/checkfirstpartitionoffset/tests/test_check_first_partition_offset.py +++ b/repos/system_upgrade/common/actors/checkfirstpartitionoffset/tests/test_check_first_partition_offset.py @@ -1,6 +1,9 @@ import pytest +from leapp import reporting from leapp.libraries.actor import check_first_partition_offset +from leapp.libraries.common import grub +from leapp.libraries.common.testutils import create_report_mocked from leapp.reporting import Report from leapp.utils.report import is_inhibitor @@ -33,3 +36,21 @@ def mocked_run(cmd, *args, **kwargs): expected = offset_bytes >= check_first_partition_offset.SAFE_OFFSET_BYTES assert expected == check_first_partition_offset.is_first_partition_offset_ok(device) + + +@pytest.mark.parametrize('devices_with_bad_offset', [tuple(), ('/dev/vda', )]) +def test_bad_offset_reported(monkeypatch, devices_with_bad_offset): + def mocked_is_partition_offset_ok(device): + return device not in devices_with_bad_offset + + def get_grub_devices_mocked(): + return ['/dev/vdb'] + list(devices_with_bad_offset) + + monkeypatch.setattr(check_first_partition_offset, 'is_first_partition_offset_ok', mocked_is_partition_offset_ok) + monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) + monkeypatch.setattr(grub, 'get_grub_devices', get_grub_devices_mocked) + + check_first_partition_offset.check_first_partition_offset() + + if devices_with_bad_offset: + assert reporting.create_report.called