Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mhecko committed Apr 3, 2024
1 parent bfac881 commit 888ec6d
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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

0 comments on commit 888ec6d

Please sign in to comment.