Skip to content

Commit cc741e7

Browse files
Add the suggestions
1 parent 8f4c98a commit cc741e7

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

fixity/reporting.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import json
33
from datetime import datetime
44
from typing import Optional
5+
from typing import Tuple
56

67
import requests
78

89
from .models import Report
9-
from .models import Session
1010
from .utils import check_valid_uuid
1111

1212

@@ -16,10 +16,10 @@ class ReportServiceException(Exception):
1616

1717
def post_pre_scan_report(
1818
aip: str,
19-
start_time: Optional[datetime],
20-
report_url: Optional[str],
21-
report_auth: Optional[str] = (),
22-
session_id: Session = None,
19+
start_time: datetime,
20+
report_url: str,
21+
report_auth: Tuple[str, str] = (),
22+
session_id: str = None,
2323
) -> bool:
2424
"""
2525
Post a pre-scan report to a remote system.
@@ -63,10 +63,10 @@ def post_pre_scan_report(
6363

6464
def post_success_report(
6565
aip: str,
66-
report: Optional[Report],
67-
report_url: Optional[str],
68-
report_auth: Optional[str] = (),
69-
session_id: Session = None,
66+
report: Report,
67+
report_url: str,
68+
report_auth: Tuple[str, str] = (),
69+
session_id: str = None,
7070
) -> Optional[bool]:
7171
"""
7272
POST a JSON fixity scan report to a remote system.

tests/test_reporting.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def test_posting_prescan_report(_post: mock.Mock) -> None:
3232

3333

3434
def test_posting_prescan_report_raises_on_invalid_uuid() -> None:
35+
start_time = datetime.fromtimestamp(1400022946)
3536
with pytest.raises(InvalidUUID):
36-
reporting.post_pre_scan_report("foo", None, None)
37+
reporting.post_pre_scan_report("foo", start_time, REPORT_URL)
3738

3839

3940
@mock.patch(
@@ -81,8 +82,16 @@ def test_posting_success_report(_post: mock.Mock) -> None:
8182

8283

8384
def test_posting_success_report_raises_on_invalid_uuid() -> None:
85+
json_report = json_string("test_failed_report.json")
86+
report = Report(
87+
begun=datetime.fromtimestamp(1400022946),
88+
ended=datetime.fromtimestamp(1400023208),
89+
success=False,
90+
posted=False,
91+
report=json_report,
92+
)
8493
with pytest.raises(InvalidUUID):
85-
reporting.post_success_report("foo", None, None)
94+
reporting.post_success_report("foo", report, REPORT_URL)
8695

8796

8897
@mock.patch(

0 commit comments

Comments
 (0)