From cd43e38c380ed0a37f1662c1e44063a0a5d9b5ba Mon Sep 17 00:00:00 2001 From: Giulia Naponiello Date: Nov 30 2018 09:50:11 +0000 Subject: Additional tests One more test for the new redhat-module subject_type, checking if the API is correctly working with it. --- diff --git a/conf/policies/redhat.yaml b/conf/policies/redhat.yaml index 90264bb..db3dfb5 100644 --- a/conf/policies/redhat.yaml +++ b/conf/policies/redhat.yaml @@ -19,6 +19,16 @@ rules: "policycoreutils", ] } +# A policy for RHEL 8 Modularity +--- !Policy +id: "osci_compose_modules" +product_versions: + - rhel-8 +decision_context: osci_compose_gate_modules +subject_type: redhat-module +blacklist: [] +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.redhat-module.tier0.functional} --- !Policy id: "rtt_compose" product_versions: diff --git a/functional-tests/test_api_v1.py b/functional-tests/test_api_v1.py index 688a5be..2ab7aca 100644 --- a/functional-tests/test_api_v1.py +++ b/functional-tests/test_api_v1.py @@ -36,7 +36,7 @@ def test_inspect_policies(requests_session, greenwave_server): assert r.status_code == 200 body = r.json() policies = body['policies'] - assert len(policies) == 10 + assert len(policies) == 11 assert any(p['id'] == 'taskotron_release_critical_tasks' for p in policies) assert any(p['decision_context'] == 'bodhi_update_push_stable' for p in policies) assert any(p['product_versions'] == ['fedora-26'] for p in policies) @@ -1065,3 +1065,29 @@ def test_make_a_decision_for_bodhi_with_verbose_flag( assert res_data['results'] == list(reversed(results)) assert res_data['waivers'] == [] assert res_data['satisfied_requirements'] == [] + + +def test_decision_on_redhat_module(requests_session, greenwave_server, testdatabuilder): + nvr = '389-ds-1.4-820181127205924.9edba152' + new_result_data = { + 'testcase': {'name': 'baseos-ci.redhat-module.tier0.functional'}, + 'outcome': 'PASSED', + 'data': {'item': nvr, 'type': 'redhat-module'} + } + result = testdatabuilder._create_result(new_result_data) # noqa + data = { + 'decision_context': 'osci_compose_gate_modules', + 'product_version': 'rhel-8', + 'subject_type': 'redhat-module', + 'subject_identifier': nvr, + 'verbose': True + } + r = requests_session.post(greenwave_server + 'api/v1.0/decision', + headers={'Content-Type': 'application/json'}, + data=json.dumps(data)) + assert r.status_code == 200 + res_data = r.json() + assert res_data['policies_satisfied'] is True + expected_summary = 'All required tests passed' + assert res_data['summary'] == expected_summary + res_data['results'][0]['data']['type'][0] == 'redhat-module'