#659 Fix matching scenario from rules
Merged 2 years ago by lholecek. Opened 2 years ago by lholecek.
lholecek/greenwave fix-matching-scenario  into  master

Fix matching scenario from rules
Lukas Holecek • 2 years ago  
@@ -1637,3 +1637,45 @@ 

          'redhat-container-image',

          'redhat-module',

      ]

+ 

+ def test_make_a_decision_on_passed_result_with_custom_scenario(

+         requests_session, greenwave_server, testdatabuilder):

+     item1_nvr = testdatabuilder.unique_nvr()

+     result1 = testdatabuilder.create_result(

+         item=item1_nvr,

+         testcase_name='test.testcase1',

+         outcome='FAILED'

+     )

+     result2 = testdatabuilder.create_result(

+         item=item1_nvr,

+         testcase_name='test.testcase1',

+         outcome='PASSED',

+         scenario='scenario1',

+     )

+     data = {

+         'product_version': 'fedora-26',

+         'subject_type': 'koji_build',

+         'subject_identifier': item1_nvr,

+         "rules": [

+             {

+                 "type": "PassingTestCaseRule",

+                 "test_case_name": "test.testcase1",

+                 "scenario": "scenario1",

+             }

+         ]

+     }

+     r = requests_session.post(greenwave_server + 'api/v1.0/decision', json=data)

+     assert r.status_code == 200

+     res_data = r.json()

+     assert res_data['policies_satisfied'] is True

+     assert res_data['summary'] == 'All required tests passed'

+     assert res_data['satisfied_requirements'] == [

+         {

+             'subject_identifier': item1_nvr,

+             'subject_type': 'koji_build',

+             'result_id': result2['id'],

+             'testcase': 'test.testcase1',

+             'source': None,

+             'type': 'test-result-passed'

+         }

+     ]

file modified
+1 -1
@@ -660,7 +660,7 @@ 

          if self.scenario is not None:

              matching_results = [

                  result for result in matching_results

-                 if self.scenario in result['data']['scenario']]

+                 if self.scenario in result['data'].get('scenario', [])]

  

          # Investigate the absence of result first.

          if not matching_results:

no initial comment

new test looks good to me +1

Pull-Request has been merged by lholecek

2 years ago