From aed2f44d595645140700a43893ffb5ce22790f71 Mon Sep 17 00:00:00 2001 From: Jeremy Thurgood Date: Tue, 10 Mar 2015 14:39:14 +0200 Subject: [PATCH] Use billing_api_resource() in tests. --- go/billing/api.py | 7 +++++-- go/billing/tests/test_api.py | 9 +++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/go/billing/api.py b/go/billing/api.py index 73cb552ac..22080248b 100644 --- a/go/billing/api.py +++ b/go/billing/api.py @@ -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 diff --git a/go/billing/tests/test_api.py b/go/billing/tests/test_api.py index c0a1c627b..0e1d694a6 100644 --- a/go/billing/tests/test_api.py +++ b/go/billing/tests/test_api.py @@ -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 ( @@ -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