Skip to content

Commit

Permalink
Added final validations for bulk analysis test (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibragins authored Sep 2, 2024
1 parent 62d4e01 commit 7a45995
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions tests/test_advanced_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_custom_rules(analysis_data):
assert 'weblogic-xml-custom-rule' in ruleset['violations'], "weblogic-xml-custom-rule triggered no violations"


def bug_mta_3663_test_bulk_analysis(analysis_data):
def test_bulk_analysis(analysis_data):
applications = [analysis_data['administracion_efectivo'], analysis_data['jee_example_app']]
clearReportDir()

Expand All @@ -70,4 +70,10 @@ def bug_mta_3663_test_bulk_analysis(analysis_data):

assert 'generating static report' in output

report_data = get_json_from_report_output_file()
report_data = get_json_from_report_output_file(False)
assert len(report_data) >= 2, "Less than 2 application analysis detected"
for current_report in report_data:
assert len(current_report['rulesets']) >= 0, "No rulesets were applied"
assert len(current_report['depItems']) >= 0, "No dependencies were found"
violations = [item for item in current_report['rulesets'] if item.get('violations')]
assert len(violations) > 0, "No issues were found";
8 changes: 6 additions & 2 deletions utils/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
from utils import constants


def get_json_from_report_output_file(**kwargs):
def get_json_from_report_output_file(return_first = True, **kwargs):
"""
Loads and returns a JSON from the output.js file of the report
Args:
return_first: flag to return only first value (default). If false - will return array of values instead.
**kwargs: Optional keyword arguments.
report_path (str): The path to the report file. If not provided,
the function will use the value of the 'REPORT_OUTPUT_PATH' environment variable.
Expand All @@ -25,7 +26,10 @@ def get_json_from_report_output_file(**kwargs):

with open(report_path + "/static-report/output.js", encoding='utf-8') as file:
js_report = file.read()
return json.loads(js_report.split('window["apps"] = ')[1])[0]
if return_first:
return json.loads(js_report.split('window["apps"] = ')[1])[0]
else:
return json.loads(js_report.split('window["apps"] = ')[1])


def assert_story_points_from_report_file():
Expand Down

0 comments on commit 7a45995

Please sign in to comment.