diff --git a/go/config.py b/go/config.py index 3fb9114f1..965d3e1a9 100644 --- a/go/config.py +++ b/go/config.py @@ -8,6 +8,8 @@ sort. """ +import copy + from go.errors import UnknownConversationType, UnknownRouterType @@ -16,6 +18,10 @@ def configured_conversation_types(): for a in _VUMI_INSTALLED_APPS.itervalues()) +def configured_conversations(): + return copy.deepcopy(_VUMI_INSTALLED_APPS) + + def obsolete_conversation_types(): return set(_VUMI_OBSOLETE_APPS) @@ -25,6 +31,10 @@ def configured_router_types(): for a in _VUMI_INSTALLED_ROUTERS.itervalues()) +def configured_routers(): + return copy.deepcopy(_VUMI_INSTALLED_ROUTERS) + + def obsolete_router_types(): return set(_VUMI_OBSOLETE_ROUTERS) diff --git a/go/tests/test_config.py b/go/tests/test_config.py index 826f778b4..3f31a3f9b 100644 --- a/go/tests/test_config.py +++ b/go/tests/test_config.py @@ -6,6 +6,7 @@ get_conversation_pkg, get_router_pkg, get_conversation_definition, get_router_definition, configured_conversation_types, configured_router_types, + configured_conversations, configured_routers, obsolete_conversation_types, obsolete_router_types) from go.errors import UnknownConversationType, UnknownRouterType @@ -15,6 +16,13 @@ def test_configured_conversation_types(self): conv_types = configured_conversation_types() self.assertEqual(conv_types['bulk_message'], 'Group Message') + def test_configured_conversations(self): + convs = configured_conversations() + self.assertEqual(convs['go.apps.bulk_message'], { + 'namespace': 'bulk_message', + 'display_name': 'Group Message', + }) + def test_obsolete_conversation_types(self): obsolete_types = obsolete_conversation_types() self.assertEqual(obsolete_types, set([ @@ -46,6 +54,13 @@ def test_configured_router_types(self): conv_types = configured_router_types() self.assertEqual(conv_types['keyword'], 'Keyword') + def test_configured_routers(self): + routers = configured_routers() + self.assertEqual(routers['go.routers.keyword'], { + 'namespace': 'keyword', + 'display_name': 'Keyword', + }) + def test_obsolete_router_types(self): obsolete_types = obsolete_router_types() self.assertEqual(obsolete_types, set([ diff --git a/go/vumitools/api.py b/go/vumitools/api.py index b861e5ad4..3881b647d 100644 --- a/go/vumitools/api.py +++ b/go/vumitools/api.py @@ -19,6 +19,9 @@ from vumi.persist.txredis_manager import TxRedisManager from vumi import log +from go.config import ( + configured_conversations, + configured_routers) from go.vumitools.account import AccountStore from go.vumitools.channel import ChannelStore from go.vumitools.contact import ContactStore @@ -29,7 +32,6 @@ from go.vumitools.credit import CreditManager from go.vumitools.token_manager import TokenManager -from django.conf import settings from django.utils.datastructures import SortedDict from vumi.message import TransportUserMessage @@ -230,7 +232,7 @@ def applications(self): app_permissions.extend((yield permissions)) applications = [permission.application for permission in app_permissions] - app_settings = settings.VUMI_INSTALLED_APPS + app_settings = configured_conversations() returnValue(SortedDict([(application, app_settings[application]) for application in sorted(applications) @@ -240,7 +242,7 @@ def applications(self): def router_types(self): # TODO: Permissions. yield None - router_settings = settings.VUMI_INSTALLED_ROUTERS + router_settings = configured_routers() returnValue(SortedDict([(router_type, router_settings[router_type]) for router_type in sorted(router_settings)]))