Dependency inject ApplicationServiceApi when creating ApplicationServicesHandler.

This commit is contained in:
Kegan Dougal 2015-02-05 17:04:59 +00:00
parent a3c6010718
commit 11e6b3d18b
3 changed files with 9 additions and 11 deletions

View file

@ -29,13 +29,9 @@ class AppServiceHandlerTestCase(unittest.TestCase):
self.mock_as_api = Mock()
hs = Mock()
hs.get_datastore = Mock(return_value=self.mock_store)
self.handler = ApplicationServicesHandler(hs) # thing being tested
# FIXME Would be nice to DI this rather than monkey patch:(
if not hasattr(self.handler, "appservice_api"):
# someone probably updated the handler but not the tests. Fail fast.
raise Exception("Test expected handler.appservice_api to exist.")
self.handler.appservice_api = self.mock_as_api
self.handler = ApplicationServicesHandler(
hs, self.mock_as_api
)
@defer.inlineCallbacks
def test_notify_interested_services(self):