|
| 1 | +import shopify |
| 2 | +import json |
| 3 | +from test.test_helper import TestCase |
| 4 | + |
| 5 | +class ApplicationCreditTest(TestCase): |
| 6 | + def test_get_application_credit(self): |
| 7 | + self.fake('application_credits/445365009', method='GET', body=self.load_fixture('application_credit'), code=200) |
| 8 | + application_credit = shopify.ApplicationCredit.find(445365009) |
| 9 | + self.assertEqual('5.00', application_credit.amount) |
| 10 | + |
| 11 | + def test_get_all_application_credits(self): |
| 12 | + self.fake('application_credits', method='GET', body=self.load_fixture('application_credits'), code=200) |
| 13 | + application_credits = shopify.ApplicationCredit.find() |
| 14 | + self.assertEqual(1, len(application_credits)) |
| 15 | + self.assertEqual(445365009, application_credits[0].id) |
| 16 | + |
| 17 | + def test_create_application_credit(self): |
| 18 | + self.fake( |
| 19 | + 'application_credits', |
| 20 | + method='POST', |
| 21 | + body=self.load_fixture('application_credit'), |
| 22 | + headers={'Content-type': 'application/json'}, |
| 23 | + code=201 |
| 24 | + ) |
| 25 | + |
| 26 | + application_credit = shopify.ApplicationCredit.create({ |
| 27 | + 'description': 'application credit for refund', |
| 28 | + 'amount': 5.0 |
| 29 | + }) |
| 30 | + |
| 31 | + expected_body = { |
| 32 | + "application_credit": { |
| 33 | + "description": "application credit for refund", |
| 34 | + "amount": 5.0 |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + self.assertEqual(expected_body, json.loads(self.http.request.data.decode("utf-8"))) |
0 commit comments