From 28c4c8330c4483b7e95d15d138b886677f527539 Mon Sep 17 00:00:00 2001 From: Dhwani Patel Date: Thu, 10 Oct 2024 16:05:59 -0600 Subject: [PATCH] Add the suggestions --- fixity/reporting.py | 17 ++++++++--------- tests/test_reporting.py | 13 +++++++++++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/fixity/reporting.py b/fixity/reporting.py index fa3998c..ea260c9 100644 --- a/fixity/reporting.py +++ b/fixity/reporting.py @@ -6,7 +6,6 @@ import requests from .models import Report -from .models import Session from .utils import check_valid_uuid @@ -16,10 +15,10 @@ class ReportServiceException(Exception): def post_pre_scan_report( aip: str, - start_time: Optional[datetime], - report_url: Optional[str], - report_auth: Optional[str] = (), - session_id: Session = None, + start_time: datetime, + report_url: str, + report_auth: str = (), + session_id: str = None, ) -> bool: """ Post a pre-scan report to a remote system. @@ -63,10 +62,10 @@ def post_pre_scan_report( def post_success_report( aip: str, - report: Optional[Report], - report_url: Optional[str], - report_auth: Optional[str] = (), - session_id: Session = None, + report: Report, + report_url: str, + report_auth: str = (), + session_id: str = None, ) -> Optional[bool]: """ POST a JSON fixity scan report to a remote system. diff --git a/tests/test_reporting.py b/tests/test_reporting.py index 8aaee42..52ee5ac 100644 --- a/tests/test_reporting.py +++ b/tests/test_reporting.py @@ -32,8 +32,9 @@ def test_posting_prescan_report(_post: mock.Mock) -> None: def test_posting_prescan_report_raises_on_invalid_uuid() -> None: + start_time = datetime.fromtimestamp(1400022946) with pytest.raises(InvalidUUID): - reporting.post_pre_scan_report("foo", None, None) + reporting.post_pre_scan_report("foo", start_time, REPORT_URL) @mock.patch( @@ -81,8 +82,16 @@ def test_posting_success_report(_post: mock.Mock) -> None: def test_posting_success_report_raises_on_invalid_uuid() -> None: + json_report = json_string("test_failed_report.json") + report = Report( + begun=datetime.fromtimestamp(1400022946), + ended=datetime.fromtimestamp(1400023208), + success=False, + posted=False, + report=json_report, + ) with pytest.raises(InvalidUUID): - reporting.post_success_report("foo", None, None) + reporting.post_success_report("foo", report, REPORT_URL) @mock.patch(