Skip to content

Commit

Permalink
updategrubcore: Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matejmatuska committed Jun 30, 2023
1 parent e0bb187 commit 2471fcc
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

from leapp import reporting
from leapp.exceptions import StopActorExecution
from leapp.libraries.actor import updategrubcore
from leapp.libraries.common import testutils
from leapp.libraries.stdlib import api, CalledProcessError
Expand Down Expand Up @@ -32,21 +31,24 @@ def __call__(self, *args):
raise_call_error(args)


def test_update_grub(monkeypatch):
@pytest.mark.parametrize('devices', [['/dev/vda'], ['/dev/vda', '/dev/vdb']])
def test_update_grub(monkeypatch, devices):
monkeypatch.setattr(reporting, "create_report", testutils.create_report_mocked())
monkeypatch.setattr(updategrubcore, 'run', run_mocked())
updategrubcore.update_grub_core('/dev/vda')
updategrubcore.update_grub_core(devices)
assert reporting.create_report.called
assert UPDATE_OK_TITLE == reporting.create_report.report_fields['title']
assert UPDATE_OK_TITLE == reporting.create_report.reports[1]['title']
assert all(dev in reporting.create_report.reports[1]['summary'] for dev in devices)


def test_update_grub_failed(monkeypatch):
@pytest.mark.parametrize('devices', [['/dev/vda'], ['/dev/vda', '/dev/vdb']])
def test_update_grub_failed(monkeypatch, devices):
monkeypatch.setattr(reporting, "create_report", testutils.create_report_mocked())
monkeypatch.setattr(updategrubcore, 'run', run_mocked(raise_err=True))
with pytest.raises(StopActorExecution):
updategrubcore.update_grub_core('/dev/vda')
updategrubcore.update_grub_core(devices)
assert reporting.create_report.called
assert UPDATE_FAILED_TITLE == reporting.create_report.report_fields['title']
assert UPDATE_FAILED_TITLE == reporting.create_report.reports[0]['title']
assert all(dev in reporting.create_report.reports[0]['summary'] for dev in devices)


def test_update_grub_negative(current_actor_context):
Expand Down

0 comments on commit 2471fcc

Please sign in to comment.