Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Use billing_api_resource() in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerith committed Mar 10, 2015
1 parent ff9d2f4 commit aed2f44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 5 additions & 2 deletions go/billing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,5 +532,8 @@ def billing_api_resource():
connection_string = app_settings.get_connection_string()
connection_pool = DictRowConnectionPool(
None, connection_string, min=app_settings.API_MIN_CONNECTIONS)
connection_pool.start()
return Root(connection_pool)
resource = Root(connection_pool)
# Tests need to know when we're connected, so stash the deferred on the
# resource for them to look at.
resource._connection_pool_started = connection_pool.start()
return resource
9 changes: 3 additions & 6 deletions go/billing/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from go.billing import settings as app_settings
from go.billing import api
from go.billing.models import Account, Transaction, MessageCost
from go.billing.utils import DummySite, DictRowConnectionPool, JSONDecoder
from go.billing.utils import DummySite, JSONDecoder
from go.base.tests.helpers import DjangoVumiApiHelper
from go.billing.django_utils import load_account_credits
from go.billing.tests.helpers import (
Expand Down Expand Up @@ -45,11 +45,8 @@ class BillingApiTestCase(VumiTestCase):

@inlineCallbacks
def setUp(self):
connection_string = app_settings.get_connection_string()
connection_pool = DictRowConnectionPool(
None, connection_string, min=app_settings.API_MIN_CONNECTIONS)
self.connection_pool = yield connection_pool.start()
root = api.Root(connection_pool)
root = api.billing_api_resource()
self.connection_pool = yield root._connection_pool_started
self.web = DummySite(root)

@inlineCallbacks
Expand Down

0 comments on commit aed2f44

Please sign in to comment.