def populate_routing_table(routing_entries): routing_table = RoutingTable() for entry in routing_entries: source, target = entry['source'], entry['target'] src_conn, src_endp = EndpointType.parse_uuid( source['uuid']) dst_conn, dst_endp = EndpointType.parse_uuid( target['uuid']) routing_table.add_entry(src_conn, src_endp, dst_conn, dst_endp) d = user_api.get_user_account() d.addCallback(save_routing_table, routing_table) return d
def test_update_routing_table_with_conversation_linked_to_itself(self): conv, router, tag = yield self._setup_routing_table() source = (u"CONVERSATION:%s:%s" % (conv.conversation_type, conv.key), u"default") endpoint_uuid = EndpointType.format_uuid(*source) routing_table = self.mk_routing_table([(source, source)]) d = self.proxy.callRemote("update_routing_table", self.campaign_key, routing_table) yield self.assert_faults( d, 400, u"Source inbound-receiving endpoint" " {u'uuid': %r} should link" " to an outbound-receiving endpoint but links to {u'uuid': %r}" % (endpoint_uuid, endpoint_uuid), )
def test_update_routing_table_with_channel_linked_to_itself(self): conv, router, tag = yield self._setup_routing_table() source = (u'TRANSPORT_TAG:pool:tag1', u'default') endpoint_uuid = EndpointType.format_uuid(*source) routing_table = self.mk_routing_table([ (source, source), ]) d = self.proxy.callRemote("update_routing_table", self.campaign_key, routing_table) yield self.assert_faults( d, 400, u"Source outbound-receiving endpoint" " {u'uuid': %r} should link" " to an inbound-receiving endpoint but links to {u'uuid':" " %r}" % (endpoint_uuid, endpoint_uuid))
def test_update_routing_table_with_channel_linked_to_itself(self): conv, router, tag = yield self._setup_routing_table() source = (u"TRANSPORT_TAG:pool:tag1", u"default") endpoint_uuid = EndpointType.format_uuid(*source) routing_table = self.mk_routing_table([(source, source)]) d = self.proxy.callRemote("update_routing_table", self.campaign_key, routing_table) yield self.assert_faults( d, 400, u"Source outbound-receiving endpoint" " {u'uuid': %r} should link" " to an inbound-receiving endpoint but links to {u'uuid':" " %r}" % (endpoint_uuid, endpoint_uuid), )
def test_update_routing_table_with_conversation_linked_to_itself(self): conv, router, tag = yield self._setup_routing_table() source = (u'CONVERSATION:%s:%s' % (conv.conversation_type, conv.key), u'default') endpoint_uuid = EndpointType.format_uuid(*source) routing_table = self.mk_routing_table([ (source, source), ]) d = self.proxy.callRemote("update_routing_table", self.campaign_key, routing_table) yield self.assert_faults( d, 400, u"Source inbound-receiving endpoint" " {u'uuid': %r} should link" " to an outbound-receiving endpoint but links to {u'uuid': %r}" % (endpoint_uuid, endpoint_uuid))
def test_parse_uuid(self): self.assertEqual(EndpointType.parse_uuid('foo::bar::baz'), ('foo::bar', 'baz'))
def test_format_uuid(self): uuid = EndpointType.format_uuid('foo', 'bar') self.assertEqual(uuid, u'foo::bar')
def test_basic_checks(self): self.basic_checks(EndpointType())