From 2471fcc2cbf180c4ce258b1fa373e2ebaafd93aa Mon Sep 17 00:00:00 2001 From: Matej Matuska Date: Fri, 30 Jun 2023 10:42:33 +0200 Subject: [PATCH] updategrubcore: Update tests --- .../tests/test_updategrubcore.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/repos/system_upgrade/common/actors/updategrubcore/tests/test_updategrubcore.py b/repos/system_upgrade/common/actors/updategrubcore/tests/test_updategrubcore.py index e65807a203..7fc9edc502 100644 --- a/repos/system_upgrade/common/actors/updategrubcore/tests/test_updategrubcore.py +++ b/repos/system_upgrade/common/actors/updategrubcore/tests/test_updategrubcore.py @@ -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 @@ -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):