Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Add support for listing invoices from account
Browse files Browse the repository at this point in the history
  • Loading branch information
yorinasub17 committed Oct 1, 2014
1 parent 4d6a69d commit 1e3854d
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 4 deletions.
Binary file removed docs/source/.change-log.rst.swp
Binary file not shown.
Binary file removed docs/source/.index.rst.swp
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/source/basic-usage.rst
Expand Up @@ -15,7 +15,7 @@ In the following example, the call to the :meth:`~recurly.Account.save` method o
>>> with mocurly():
>>> recurly.Account(account_code='foo').save()

Note that you still have to set the `API_KEY` and `SUBDOMAIN` on the Recurly instance, since the Recurly client itself has assertions to make sure they are set. However, the values you use do not matter. They also can be set outside the Mocurly context, as in the example.
Note that you still have to set the `API_KEY` and `SUBDOMAIN` on the Recurly instance, since the Recurly client itself has assertions to make sure they are set. However, the values you use do not matter. They also have to be set outside the Mocurly context, as in the example.

Mocurly can be used as a decorator, context manager, or manually. In all 3 cases, the Mocurly context is reset at the start of the invocation.

Expand Down
5 changes: 5 additions & 0 deletions docs/source/change-log.rst
Expand Up @@ -4,6 +4,11 @@
Change log
==========

0.1.3
-----

- Implement listing of invoices from account

0.1.2
-----

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Expand Up @@ -55,7 +55,7 @@
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags.
release = '0.1.1'
release = '0.1.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 5 additions & 0 deletions mocurly/endpoints.py
Expand Up @@ -203,6 +203,11 @@ def get_transactions_list(self, pk, filters=None, format=BaseRecurlyEndpoint.XML
out = TransactionsEndpoint.backend.list_objects(lambda transaction: transaction['account'] == pk)
return transactions_endpoint.serialize(out, format=format)

@details_route('GET', 'invoices', is_list=True)
def get_invoices_list(self, pk, filters=None, format=BaseRecurlyEndpoint.XML):
out = InvoicesEndpoint.backend.list_objects(lambda invoice: invoice['account'] == pk)
return invoices_endpoint.serialize(out, format=format)

@details_route('GET', 'subscriptions', is_list=True)
def get_subscriptions_list(self, pk, filters=None, format=BaseRecurlyEndpoint.XML):
def filter_subscriptions(subscription):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -6,12 +6,12 @@
name='mocurly',
packages=find_packages(exclude=("tests", "tests.*")),
package_data={'mocurly': ['templates/*.xml']},
version='0.1.2',
version='0.1.3',
description='A library that allows your python tests to easily mock out the recurly library',
author='Yoriyasu Yano',
author_email='yoriy@captricity.com',
url='https://github.com/Captricity/mocurly',
download_url='https://github.com/Captricity/mocurly/tarball/v0.1.2',
download_url='https://github.com/Captricity/mocurly/tarball/v0.1.3',
keywords = ['testing'],
install_requires=install_requires,
test_suite='tests'
Expand Down
28 changes: 28 additions & 0 deletions tests/test_account.py
@@ -1,5 +1,6 @@
import unittest
import datetime
import operator
import iso8601
import recurly
recurly.API_KEY = 'blah'
Expand Down Expand Up @@ -262,3 +263,30 @@ def test_list_account(self):

self.assertEqual(len(accounts), 3)
self.assertEqual(set([account.account_code for account in accounts]), set(['foo', 'bar', 'blah']))

def test_invoice_list(self):
mocurly.backend.accounts_backend.add_object(self.base_account_data['account_code'], self.base_account_data)
base_invoice_data = {
'account': self.base_account_data['account_code'],
'uuid': 'foo',
'state': 'collected',
'invoice_number': '1234',
'subtotal_in_cents': 1000,
'currency': 'USD',
'created_at': '2014-08-11',
'net_terms': 0,
'collection_method': 'automatic',

'tax_type': 'usst',
'tax_rate': 0,
'tax_in_cents': 0,
'total_in_cents': 1000,
}
mocurly.backend.invoices_backend.add_object('1234', base_invoice_data)
base_invoice_data['invoice_number'] = '1235'
mocurly.backend.invoices_backend.add_object('1235', base_invoice_data)

account = recurly.Account.get(self.base_account_data['account_code'])
invoices = account.invoices()
self.assertEqual(len(invoices), 2)
self.assertEqual(set(map(operator.attrgetter('invoice_number'), invoices)), set([1234, 1235]))

0 comments on commit 1e3854d

Please sign in to comment.