Skip to content

Commit 2ec5c7f

Browse files
committed
Add tests
1 parent 6a246f0 commit 2ec5c7f

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

shopify/resources/fulfillment_event.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
from ..base import ShopifyResource
22

33
class FulfillmentEvent(ShopifyResource):
4-
_prefix_source = "/orders/$order_id/fulfillments/$fulfillment_id"
5-
_singular = "event"
6-
_plural = "events"
4+
_prefix_source = "/orders/$order_id/fulfillments/$fulfillment_id/"
5+
_singular = 'event'
6+
_plural = 'events'
77

88
@classmethod
99
def _prefix(cls, options={}):
1010
order_id = options.get("order_id")
1111
fulfillment_id = options.get('fulfillment_id')
12-
if order_id:
13-
return "%s/orders/%s/fulfillments/%s" % (
14-
cls.site, order_id, fulfillment_id)
15-
else:
16-
return cls.site
12+
event_id = options.get("event_id")
13+
14+
return "%s/orders/%s/fulfillments/%s" % (
15+
cls.site, order_id, fulfillment_id)
1716

1817
def save(self):
1918
status = self.attributes['status']

test/fixtures/fulfillment_event.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"fulfillment_event": {
3+
"id": 12584341209251,
4+
"fulfillment_id": 2608403447971,
5+
"status": "label_printed",
6+
"message": null,
7+
"happened_at": "2021-01-25T16:32:23-05:00",
8+
"city": null,
9+
"province": null,
10+
"country": null,
11+
"zip": null,
12+
"address1": null,
13+
"latitude": null,
14+
"longitude": null,
15+
"shop_id": 49144037539,
16+
"created_at": "2021-01-25T16:32:23-05:00",
17+
"updated_at": "2021-01-25T16:32:23-05:00",
18+
"estimated_delivery_at": null,
19+
"order_id": 2776493818019,
20+
"admin_graphql_api_id": "gid://shopify/FulfillmentEvent/12584341209251"
21+
}
22+
}

test/fulfillment_event_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import shopify
2+
from test.test_helper import TestCase
3+
from pyactiveresource.activeresource import ActiveResource
4+
5+
class FulFillmentEventTest(TestCase):
6+
def setUp(self):
7+
super(FulFillmentEventTest, self).setUp()
8+
self.fake("orders/450789469/fulfillments/255858046/events", method='GET', body=self.load_fixture('fulfillment_event'))
9+
10+
def test_get_fulfillment_event(self):
11+
fulfillment_event = shopify.FulfillmentEvent.find(order_id='450789469', fulfillment_id='255858046')
12+
self.assertEqual(1, len(fulfillment_event))
13+
14+
# def test_create_fulfillment_event(self):
15+
16+
17+
def test_error_on_incorrect_status(self):
18+
with self.assertRaises(AttributeError):
19+
incorrect_status = 'asdf'
20+
fulfillment_event = shopify.FulfillmentEvent.find(order_id='450789469', fulfillment_id='255858046')
21+
fulfillment_event.status = incorrect_status
22+
fulfillment_event.save()

0 commit comments

Comments
 (0)