diff --git a/channels/routing.py b/channels/routing.py index 41ab0b0..0806bd5 100644 --- a/channels/routing.py +++ b/channels/routing.py @@ -141,7 +141,7 @@ class Route(object): """ Returns the channel names this route listens on """ - return self.channel + return {self.channel,} def __str__(self): return "%s %s -> %s" % ( @@ -204,7 +204,7 @@ class Include(object): """ result = set() for entry in self.routing: - result.union(entry.channel_names()) + result.update(entry.channel_names()) return result diff --git a/channels/tests/test_routing.py b/channels/tests/test_routing.py index 5605175..bfc44cd 100644 --- a/channels/tests/test_routing.py +++ b/channels/tests/test_routing.py @@ -281,3 +281,24 @@ class RoutingTests(SimpleTestCase): consumer=consumer_2, kwargs={"version": "2", "room": "django"}, ) + + def test_channels(self): + """ + Tests that the router reports channels to listen on correctly + """ + router = Router([ + route("http.request", consumer_1, path=r"^/chat/$"), + route("http.disconnect", consumer_2), + route("http.request", consumer_3), + ]) + # Initial check + self.assertEqual( + router.channels, + {"http.request", "http.disconnect"}, + ) + # Dynamically add route, recheck + router.add_route(route("websocket.receive", consumer_1)) + self.assertEqual( + router.channels, + {"http.request", "http.disconnect", "websocket.receive"}, + )