| |
@@ -20,7 +20,8 @@
|
| |
TestResultPassed,
|
| |
InvalidRemoteRuleYaml,
|
| |
MissingRemoteRuleYaml,
|
| |
- OnDemandPolicy
|
| |
+ OnDemandPolicy,
|
| |
+ NoTestsRequired
|
| |
)
|
| |
from greenwave.resources import ResultsRetriever
|
| |
from greenwave.safe_yaml import SafeYAMLError
|
| |
@@ -778,6 +779,45 @@
|
| |
assert decision[0].is_satisfied is False
|
| |
|
| |
|
| |
+ def test_remote_rule_policy_empty_rule(tmpdir):
|
| |
+ subject = create_subject('koji_build', 'nethack-1.2.3-1.el9000')
|
| |
+
|
| |
+ serverside_fragment = dedent("""
|
| |
+ --- !Policy
|
| |
+ id: "taskotron_release_critical_tasks_with_remoterule"
|
| |
+ product_versions:
|
| |
+ - fedora-26
|
| |
+ decision_context: bodhi_update_push_stable_with_remoterule
|
| |
+ subject_type: koji_build
|
| |
+ rules:
|
| |
+ - !RemoteRule {}
|
| |
+ """)
|
| |
+
|
| |
+ remote_fragment = dedent("""
|
| |
+ --- !Policy
|
| |
+ decision_context: bodhi_update_push_stable_with_remoterule
|
| |
+ rules:
|
| |
+ - !EmptyRule {}
|
| |
+ """)
|
| |
+
|
| |
+ p = tmpdir.join('gating.yaml')
|
| |
+ p.write(serverside_fragment)
|
| |
+ with mock.patch('greenwave.resources.retrieve_scm_from_koji') as scm:
|
| |
+ scm.return_value = ('rpms', 'nethack', 'c3c47a08a66451cb9686c49f040776ed35a0d1bb')
|
| |
+ with mock.patch('greenwave.resources.retrieve_yaml_remote_rule') as f:
|
| |
+ f.return_value = remote_fragment
|
| |
+ policies = load_policies(tmpdir.strpath)
|
| |
+ policy = policies[0]
|
| |
+
|
| |
+ results = DummyResultsRetriever()
|
| |
+ print(results)
|
| |
+ decision = policy.check('fedora-26', subject, results)
|
| |
+ print(decision)
|
| |
+ assert len(decision) == 1
|
| |
+ assert isinstance(decision[0], NoTestsRequired)
|
| |
+ assert decision[0].is_satisfied is True
|
| |
+
|
| |
+
|
| |
def test_remote_rule_malformed_yaml(tmpdir):
|
| |
""" Testing the RemoteRule with a malformed gating.yaml file """
|
| |
|
| |
Why not use
rules: []
instead?