File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 1
1
from ..base import ShopifyResource
2
2
from shopify import mixins
3
3
from .customer_invite import CustomerInvite
4
+ from .order import Order
4
5
5
6
6
7
class Customer (ShopifyResource , mixins .Metafields ):
@@ -24,3 +25,6 @@ def search(cls, **kwargs):
24
25
def send_invite (self , customer_invite = CustomerInvite ()):
25
26
resource = self .post ("send_invite" , customer_invite .encode ())
26
27
return CustomerInvite (Customer .format .decode (resource .body ))
28
+
29
+ def orders (self ):
30
+ return Order .find (customer_id = self .id )
Original file line number Diff line number Diff line change @@ -53,3 +53,12 @@ def test_send_invite_with_params(self):
53
53
self .assertEqual (customer_invite , json .loads (self .http .request .data .decode ("utf-8" )))
54
54
self .assertIsInstance (customer_invite_response , shopify .CustomerInvite )
55
55
self .assertEqual (customer_invite ['customer_invite' ]['to' ], customer_invite_response .to )
56
+
57
+ def test_get_customer_orders (self ):
58
+ self .fake ('customers/207119551' , method = 'GET' , body = self .load_fixture ('customer' ))
59
+ customer = shopify .Customer .find (207119551 )
60
+ self .fake ('customers/207119551/orders' , method = 'GET' , body = self .load_fixture ('orders' ))
61
+ orders = customer .orders ()
62
+ self .assertIsInstance (orders [0 ], shopify .Order )
63
+ self .assertEqual (450789469 , orders [0 ].id )
64
+ self .assertEqual (207119551 , orders [0 ].customer .id )
You can’t perform that action at this time.
0 commit comments