diff --git a/britney2/policies/cloud.py b/britney2/policies/cloud.py index 56fa755..ad0e591 100644 --- a/britney2/policies/cloud.py +++ b/britney2/policies/cloud.py @@ -97,7 +97,12 @@ class CloudPolicy(BasePolicy): def apply_src_policy_impl(self, policy_info, item, source_data_tdist, source_data_srcdist, excuse): self.logger.info("Cloud Policy: Looking at {}".format(item.package)) if item.package not in self.package_set: - return PolicyVerdict.PASS + verdict = PolicyVerdict.PASS + excuse.add_verdict_info( + verdict, + "Cloud tests not required because package is not in the cloud package set." + ) + return verdict if self.dry_run: self.logger.info( @@ -123,7 +128,9 @@ class CloudPolicy(BasePolicy): return verdict else: self._cleanup_work_directory() - return PolicyVerdict.PASS + verdict = PolicyVerdict.PASS + excuse.add_verdict_info(verdict, "Cloud tests passed.") + return verdict def _mark_tests_run(self, package, version, series, source_type, cloud): """Mark the selected package version as already tested. diff --git a/tests/test_cloud.py b/tests/test_cloud.py index 8129cef..1bd23b0 100644 --- a/tests/test_cloud.py +++ b/tests/test_cloud.py @@ -11,12 +11,13 @@ import json import sys from types import SimpleNamespace import unittest -from unittest.mock import patch +from unittest.mock import MagicMock, patch import xml.etree.ElementTree as ET PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, PROJECT_DIR) +from britney2.policies import PolicyVerdict from britney2.policies.cloud import CloudPolicy, ERR_MESSAGE, MissingURNException class FakeItem: @@ -143,7 +144,7 @@ class T(unittest.TestCase): self.policy.options.series = "jammy" self.policy.apply_src_policy_impl( - None, FakeItem, None, FakeSourceData, None + None, FakeItem, None, FakeSourceData, MagicMock() ) mock_run.assert_called_once_with( @@ -157,11 +158,12 @@ class T(unittest.TestCase): self.policy.package_set = set(["vim"]) self.policy.options.series = "jammy" - self.policy.apply_src_policy_impl( - None, FakeItem, None, FakeSourceData, None + verdict = self.policy.apply_src_policy_impl( + None, FakeItem, None, FakeSourceData, MagicMock() ) mock_run.assert_not_called() + self.assertEqual(verdict, PolicyVerdict.PASS) @patch("britney2.policies.cloud.smtplib") @patch("britney2.policies.cloud.CloudPolicy._run_cloud_tests")