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