Skip to content

Commit dd46a65

Browse files
authored
Merge pull request #93 from Justintime50/fix-unit-tests
Fix unit tests
2 parents c19a380 + 54229ef commit dd46a65

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ test
2525
virtualenv
2626
.virtualenv
2727
.idea
28+
.coverage

tests/test_batch.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Unit tests related to 'Batch' (https://www.easypost.com/docs/api#batches).
22

33
import easypost
4-
54
from time import sleep
65

7-
86
def test_batch_create_and_buy():
9-
# We create Address and Parcel objects. We then try to create a Batch containing a shipment. Finally,
7+
# We create Address and Parcel objects. We then try to create a Batch containing a shipment.
108
# Finally, we assert on saved and returned data.
119

1210
# from address and parcel don't change
@@ -75,7 +73,7 @@ def test_batch_create_and_buy():
7573

7674
# Assert on fees
7775
assert batch.shipments[0].fees[0].amount == '0.01000'
78-
assert batch.shipments[0].fees[1].amount == '7.65000'
76+
assert batch.shipments[0].fees[1].amount == '7.68000'
7977
assert batch.shipments[0].fees[2].amount == '1.00000'
8078

8179
# Assert on parcel

tests/test_pickup.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,32 @@
22

33
import time
44
import datetime
5-
65
import easypost
76
import pytest
87
import pytz
98

10-
119
ONE_DAY = datetime.timedelta(days=1)
1210

13-
1411
@pytest.fixture
1512
def noon_on_next_monday():
1613
today = datetime.date.today()
1714
next_monday = today + datetime.timedelta(days=(7 - today.weekday()))
1815
noon_est = datetime.time(12, 0, tzinfo=pytz.timezone('America/New_York'))
1916
return datetime.datetime.combine(next_monday, noon_est)
2017

21-
2218
def test_pickup_batch(noon_on_next_monday):
2319
# Create a Batch containing multiple Shipments. Then we try to buy a Pickup and assert if it was bought.
2420

2521
pickup_address = easypost.Address.create(
2622
verify=['delivery'],
27-
name='Jarrett Streebin',
23+
name='TAKASHI KOVACS',
2824
company='EasyPost',
29-
street1='1 MONTGOMERY ST STE 400',
30-
city='San Francisco',
31-
state='CA',
32-
zip='94104',
25+
street1='2889 W ASHTON BLVD',
26+
street2='SUITE 325',
27+
city='Lehi',
28+
state='UT',
29+
zip='84042',
30+
country='US',
3331
phone='415-456-7890'
3432
)
3533

@@ -102,18 +100,19 @@ def test_pickup_batch(noon_on_next_monday):
102100
service=pickup.pickup_rates[0].service
103101
)
104102

105-
106103
def test_single_pickup(noon_on_next_monday):
107104
"""Create a Shipment, buy it, and then buy a pickup for it"""
108105

109106
pickup_address = easypost.Address.create(
110107
verify=['delivery'],
111-
name='Jarrett Streebin',
108+
name='TAKASHI KOVACS',
112109
company='EasyPost',
113-
street1='1 MONTGOMERY ST STE 400',
114-
city='San Francisco',
115-
state='CA',
116-
zip='94104',
110+
street1='2889 W ASHTON BLVD',
111+
street2='SUITE 325',
112+
city='Lehi',
113+
state='UT',
114+
zip='84042',
115+
country='US',
117116
phone='415-456-7890'
118117
)
119118

@@ -144,7 +143,7 @@ def test_single_pickup(noon_on_next_monday):
144143
instructions='Special pickup instructions'
145144
)
146145

147-
assert pickup.pickup_rates != []
146+
assert pickup.pickup_rates != [], pickup.messages
148147

149148
pickup.buy(
150149
carrier=pickup.pickup_rates[0].carrier,

tests/test_report.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Unit tests related to 'Report's (https://www.easypost.com/docs/api.html#reports).
22

33
import easypost
4+
from datetime import date
45

6+
# Use the current date to avoid needing to define a new date manually on each test
7+
today = date.today()
8+
testdate = today.strftime("%Y/%m/%d")
59

610
def test_shipment_report():
711
report = easypost.Report.create(
812
type="shipment",
9-
start_date="2012-12-01",
10-
end_date="2013-01-01",
13+
start_date=testdate,
14+
end_date=testdate,
1115
)
1216

1317
assert report.object == "ShipmentReport"

0 commit comments

Comments
 (0)