|
4 | 4 |
|
5 | 5 | easypost.api_key = api_key
|
6 | 6 |
|
| 7 | + |
7 | 8 | class ReportTests(unittest.TestCase):
|
8 | 9 |
|
9 |
| - def test_report(self): |
10 |
| - report = easypost.Report.create( |
11 |
| - start_date="2012-12-01", |
12 |
| - end_date="2013-01-01", |
13 |
| - type="shipment" |
14 |
| - ) |
| 10 | + def test_shipment_report(self): |
| 11 | + report = easypost.Report.create( |
| 12 | + start_date="2012-12-01", |
| 13 | + end_date="2013-01-01", |
| 14 | + type="shipment" |
| 15 | + ) |
| 16 | + |
| 17 | + assert report.object == "ShipmentReport" |
| 18 | + assert report.status == "available" |
| 19 | + assert report.__class__ == easypost.Report |
| 20 | + |
| 21 | + report2 = easypost.Report.retrieve(report.id, api_key=api_key) |
| 22 | + |
| 23 | + assert report2.__class__ == easypost.Report |
| 24 | + assert report2.id == report.id |
| 25 | + |
| 26 | + reports = easypost.Report.all(api_key=api_key, type="shipment") |
| 27 | + assert len(reports["reports"]) |
| 28 | + assert reports["reports"][0].id == report.id == report2.id |
| 29 | + |
| 30 | + def test_payment_log_report(self): |
| 31 | + report = easypost.Report.create( |
| 32 | + start_date="2012-12-01", |
| 33 | + end_date="2013-01-01", |
| 34 | + type="payment_log" |
| 35 | + ) |
| 36 | + |
| 37 | + assert report.object == "PaymentLogReport" |
| 38 | + assert report.status == "available" |
| 39 | + assert report.__class__ == easypost.Report |
| 40 | + |
| 41 | + report2 = easypost.Report.retrieve(report.id, api_key=api_key) |
| 42 | + |
| 43 | + assert report2.__class__ == easypost.Report |
| 44 | + assert report2.id == report.id |
| 45 | + |
| 46 | + reports = easypost.Report.all(api_key=api_key, type="payment_log") |
| 47 | + assert len(reports["reports"]) |
| 48 | + assert reports["reports"][0].id == report.id == report2.id |
| 49 | + |
| 50 | + def test_tracker_report(self): |
| 51 | + report = easypost.Report.create( |
| 52 | + start_date="2012-12-01", |
| 53 | + end_date="2013-01-01", |
| 54 | + type="tracker" |
| 55 | + ) |
| 56 | + |
| 57 | + assert report.object == "TrackerReport" |
| 58 | + # assert report.status == "available" # Not yet implemented for tracker reports |
| 59 | + assert report.__class__ == easypost.Report |
15 | 60 |
|
16 |
| - assert report.object == "ShipmentReport" |
17 |
| - assert report.status == "available" |
| 61 | + report2 = easypost.Report.retrieve(report.id, api_key=api_key) |
18 | 62 |
|
19 |
| - report2 = easypost.Report.retrieve(report.id, api_key=api_key) |
20 |
| - assert report2.id == report.id |
| 63 | + assert report2.__class__ == easypost.Report |
| 64 | + assert report2.id == report.id |
21 | 65 |
|
22 |
| - reports = easypost.Report.all(api_key=api_key, type = "shipment") |
23 |
| - assert len(reports["reports"]) |
24 |
| - assert reports["reports"][0].id == report.id == report2.id |
| 66 | + reports = easypost.Report.all(api_key=api_key, type="tracker") |
| 67 | + assert len(reports["reports"]) |
| 68 | + assert reports["reports"][0].id == report.id == report2.id |
0 commit comments