def test_fail(self, kernel_getter, req_getter1, req_getter2, req_getter3, req_getter4): """Test the failed ResolvePackagesTask task.""" kernel_getter.return_value = None req_getter1.return_value = [] req_getter2.return_value = [] req_getter3.return_value = [] req_getter4.return_value = [] selection = PackagesSelectionData() dnf_manager = Mock() dnf_manager.default_environment = None dnf_manager.disable_modules.side_effect = MissingSpecsError("e1") dnf_manager.apply_specs.side_effect = MissingSpecsError("e2") with pytest.raises(NonCriticalInstallationError) as cm: task = ResolvePackagesTask(dnf_manager, selection) task.run() expected = "e1\n\ne2" assert str(cm.value) == expected dnf_manager.enable_modules.side_effect = BrokenSpecsError("e3") dnf_manager.resolve_selection.side_effect = InvalidSelectionError("e4") with pytest.raises(PayloadInstallationError) as cm: task = ResolvePackagesTask(dnf_manager, selection) task.run() expected = "e3\n\ne4" assert str(cm.value) == expected
def check_invalid_selection_test(self, kernel_getter): kernel_getter.return_value = None selection = PackagesSelectionData() dnf_manager = Mock() dnf_manager.disable_modules.side_effect = MissingSpecsError("e1") dnf_manager.enable_modules.side_effect = BrokenSpecsError("e2") dnf_manager.apply_specs.side_effect = MissingSpecsError("e3") dnf_manager.resolve_selection.side_effect = InvalidSelectionError("e4") task = CheckPackagesSelectionTask(dnf_manager, selection) report = task.run() self.assertEqual(report.error_messages, ["e2", "e4"]) self.assertEqual(report.warning_messages, ["e1", "e3"])