Skip to content

Commit 684947b

Browse files
committed
Initial commit of application_credit.py and tests
1 parent 4f2f800 commit 684947b

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

shopify/resources/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .tax_line import TaxLine
1818
from .script_tag import ScriptTag
1919
from .application_charge import ApplicationCharge
20+
from .application_credit import ApplicationCredit
2021
from .recurring_application_charge import RecurringApplicationCharge
2122
from .usage_charge import UsageCharge
2223
from .asset import Asset
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from ..base import ShopifyResource
2+
3+
class ApplicationCredit(ShopifyResource):
4+
_prefix_source = "application_credits/$application_credit_id/"
5+
6+
@classmethod
7+
def _prefix(cls, options={}):
8+
application_credit_id = options.get("application_credit_id")
9+
if application_credit_id:
10+
return "%s/application_credits/%s" % (cls.site, application_credit_id)
11+
else:
12+
return "%s" % (cls.site)

test/application_credit_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import shopify
2+
from test.test_helper import TestCase
3+
from pyactiveresource.activeresource import ActiveResource
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'))
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'))
13+
application_credits = shopify.ApplicationCredit.find()
14+
self.assertEqual(1, len(application_credits))
15+
self.assertEqual(445365009, application_credits[0].id)

test/fixtures/application_credit.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"application_credit": {
3+
"id": 445365009,
4+
"amount": "5.00",
5+
"description": "credit for application refund",
6+
"test": null
7+
}
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"application_credits": [
3+
{
4+
"id": 445365009,
5+
"amount": "5.00",
6+
"description": "credit for application refund",
7+
"test": null
8+
}
9+
]
10+
}

0 commit comments

Comments
 (0)