Skip to content

Commit

Permalink
Add a test for getting a customer and creating a customer.
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith committed Jul 10, 2015
1 parent 516d76c commit 932f939
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/customer_test.py
Expand Up @@ -3,6 +3,25 @@

class CustomerTest(TestCase):

def test_create_customer(self):
self.fake("customers", method='POST', body=self.load_fixture('customer'), headers={'Content-type': 'application/json'})
customer = shopify.Customer()
customer.first_name = 'Bob'
customer.last_name = 'Lastnameson'
customer.email = 'steve.lastnameson@example.com'
customer.verified_email = True
customer.password = "newpass"
customer.password_confirmation = "newpass"
self.assertEqual("newpass", customer.attributes['password'])
customer.save()
self.assertEqual("Bob", customer.first_name)
self.assertEqual("newpass", customer.attributes['password'])

def test_get_customer(self):
self.fake('customers/207119551', method='GET', body=self.load_fixture('customer'))
customer = shopify.Customer.find(207119551)
self.assertEqual("Bob", customer.first_name)

def test_search(self):
self.fake("customers/search.json?query=Bob+country%3AUnited+States", extension=False, body=self.load_fixture('customers_search'))

Expand Down
59 changes: 59 additions & 0 deletions test/fixtures/customer.json
@@ -0,0 +1,59 @@
{
"customer": {
"accepts_marketing": false,
"created_at": "2015-05-27T18:11:24-04:00",
"email": "bob.norman@hostmail.com",
"first_name": "Bob",
"id": 207119551,
"last_name": "Norman",
"last_order_id": 450789469,
"multipass_identifier": null,
"note": null,
"orders_count": 1,
"state": "disabled",
"tax_exempt": false,
"total_spent": "41.94",
"updated_at": "2015-05-27T18:11:24-04:00",
"verified_email": true,
"tags": "",
"last_order_name": "#1001",
"default_address": {
"address1": "Chestnut Street 92",
"address2": "",
"city": "Louisville",
"company": null,
"country": "United States",
"first_name": null,
"id": 207119551,
"last_name": null,
"phone": "555-625-1199",
"province": "Kentucky",
"zip": "40202",
"name": "",
"province_code": "KY",
"country_code": "US",
"country_name": "United States",
"default": true
},
"addresses": [
{
"address1": "Chestnut Street 92",
"address2": "",
"city": "Louisville",
"company": null,
"country": "United States",
"first_name": null,
"id": 207119551,
"last_name": null,
"phone": "555-625-1199",
"province": "Kentucky",
"zip": "40202",
"name": "",
"province_code": "KY",
"country_code": "US",
"country_name": "United States",
"default": true
}
]
}
}

0 comments on commit 932f939

Please sign in to comment.