Skip to content

Commit

Permalink
Add the suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhwaniartefact committed Oct 11, 2024
1 parent 8f4c98a commit 28c4c83
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
17 changes: 8 additions & 9 deletions fixity/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import requests

from .models import Report
from .models import Session
from .utils import check_valid_uuid


Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 11 additions & 2 deletions tests/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 28c4c83

Please sign in to comment.