Skip to content

Commit f2afa6c

Browse files
committed
Add test_create_application_credit() function
1 parent 684947b commit f2afa6c

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

test/application_credit_test.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
11
import shopify
2+
import json
23
from test.test_helper import TestCase
34
from pyactiveresource.activeresource import ActiveResource
45

56
class ApplicationCreditTest(TestCase):
67
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)
89
application_credit = shopify.ApplicationCredit.find(445365009)
910
self.assertEqual('5.00', application_credit.amount)
1011

1112
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)
1314
application_credits = shopify.ApplicationCredit.find()
1415
self.assertEqual(1, len(application_credits))
1516
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

Comments
 (0)