Skip to content

Commit

Permalink
Fix invoices (customer_uuid) and data_source (system)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkopac committed Feb 22, 2017
1 parent a953496 commit 963db27
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chartmogul/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"""

__title__ = 'chartmogul'
__version__ = '1.0.2'
__version__ = '1.0.3'
__build__ = 0x000000
__author__ = 'ChartMogul Ltd'
__license__ = 'MIT'
Expand Down
1 change: 1 addition & 0 deletions chartmogul/api/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class _Schema(Schema):
name = fields.String()
created_at = fields.DateTime()
status = fields.Str()
system = fields.Str()

@post_load
def make(self, data):
Expand Down
2 changes: 1 addition & 1 deletion chartmogul/imp/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Invoice(Resource):
"""
_path = "/import/customers{/uuid}/invoices"
_root_key = 'invoices'
_many = namedtuple('Invoices', [_root_key, "current_page", "total_pages"])
_many = namedtuple('Invoices', [_root_key, "current_page", "total_pages", "customer_uuid"])
_many.__new__.__defaults__ = (None,) * len(_many._fields)

class _Schema(Schema):
Expand Down
23 changes: 22 additions & 1 deletion test/imp/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ class InvoiceTestCase(unittest.TestCase):

@requests_mock.mock()
def test_create(self, mock_requests):

mock_requests.register_uri(
'POST',
"https://api.chartmogul.com/v1/import/customers/UUID/invoices",
Expand All @@ -172,3 +171,25 @@ def test_create(self, mock_requests):
# Struct too complex to do 1:1 comparison
self.assertTrue(isinstance(result, Invoice._many))
self.assertEqual(len(result.invoices), 1)

@requests_mock.mock()
def test_list_has_customer_uuid(self, mock_requests):
responseData['customer_uuid'] = 'UUID'

mock_requests.register_uri(
'GET',
"https://api.chartmogul.com/v1/import/customers/UUID/invoices",
request_headers={'Authorization': 'Basic dG9rZW46c2VjcmV0'},
status_code=200,
json=responseData
)

config = Config("token", "secret") # is actually checked in mock
result = Invoice.all(config, uuid="UUID").get()

self.assertEqual(mock_requests.call_count, 1, "expected call")
self.assertEqual(mock_requests.last_request.qs, {})
# Struct too complex to do 1:1 comparison
self.assertTrue(isinstance(result, Invoice._many))
self.assertEqual(len(result.invoices), 1)
self.assertEqual(result.customer_uuid, 'UUID')

0 comments on commit 963db27

Please sign in to comment.