From 22f865d7ae8110884f3f018aaa97c8e4d884fe1b Mon Sep 17 00:00:00 2001 From: Aleksa Svitlica Date: Thu, 23 Mar 2023 15:26:20 -0400 Subject: [PATCH] feat(cloud): Add verdict info for passed tests Additional verdict info is being provided by the CloudPolicy to improve clarity on the state of cloud tests. When tests pass this will be marked in the verdict. Also when a package is skipped because it is not in the cloud package set this will be made clear in the verdict. --- britney2/policies/cloud.py | 11 +++++++++-- tests/test_cloud.py | 10 ++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) 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")