From 435e24378f999bbc0eb9ac11ff4ec7984ada809f Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Mon, 16 Oct 2023 11:22:56 +0200 Subject: [PATCH] fix formatting --- steps/gather/src/handler/gather.py | 30 ++++++++++++------- steps/gather/test/fixture/__init__.py | 1 + steps/gather/test/unit/handler/test_gather.py | 12 +++++--- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/steps/gather/src/handler/gather.py b/steps/gather/src/handler/gather.py index 4eaa3f4..6c23baa 100644 --- a/steps/gather/src/handler/gather.py +++ b/steps/gather/src/handler/gather.py @@ -34,14 +34,18 @@ def gather_results(event, context): ) master_report = deepcopy(account_reports[0]["report"]) - master_report = list(unique_everseen([ - { - k: v - for k, v in elem.items() - if k in ["plugin", "category", "title", "description"] - } - for elem in master_report - ])) + master_report = list( + unique_everseen( + [ + { + k: v + for k, v in elem.items() + if k in ["plugin", "category", "title", "description"] + } + for elem in master_report + ] + ) + ) for plugin in master_report: plugin["reports"] = { report["account"]: [ @@ -56,8 +60,14 @@ def gather_results(event, context): for report in account_reports } - master_report_by_category = {k:list(v) for k,v in groupby(master_report, key=itemgetter("category"))} + master_report_by_category = { + k: list(v) for k, v in groupby(master_report, key=itemgetter("category")) + } - result = s3.put_object(Bucket=bucket, Key=f"{date}/report.json", Body=json.dumps(master_report_by_category).encode()) + result = s3.put_object( + Bucket=bucket, + Key=f"{date}/report.json", + Body=json.dumps(master_report_by_category).encode(), + ) return master_report_by_category diff --git a/steps/gather/test/fixture/__init__.py b/steps/gather/test/fixture/__init__.py index bf06b57..4d22f42 100644 --- a/steps/gather/test/fixture/__init__.py +++ b/steps/gather/test/fixture/__init__.py @@ -1,5 +1,6 @@ from pathlib import Path + def read_test_scan_reports(): report_files = ["123123123123.json", "456456456456.json", "789789789789.json"] diff --git a/steps/gather/test/unit/handler/test_gather.py b/steps/gather/test/unit/handler/test_gather.py index c3d033b..00a973e 100644 --- a/steps/gather/test/unit/handler/test_gather.py +++ b/steps/gather/test/unit/handler/test_gather.py @@ -44,12 +44,16 @@ def test_should_create_master_report(): assert_that(category, is_(instance_of(str))) for plugin in plugins: for key in plugin.keys(): - assert_that(key, is_in(["plugin", "category", "title", "description", "reports"])) + assert_that( + key, + is_in(["plugin", "category", "title", "description", "reports"]), + ) for account, findings in plugin["reports"].items(): assert_that(account, is_(instance_of(str))) for finding in findings: for finding_property in finding.keys(): - assert_that(finding_property, is_in(["resource", "region", "status", "message"])) - - + assert_that( + finding_property, + is_in(["resource", "region", "status", "message"]), + )