From 24cf5bbb848a7beea06b0ba36e73dd76f8be3931 Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Wed, 30 Oct 2019 14:17:05 -0400 Subject: [PATCH] Make discussion stub server URL handling deterministic BOM-994 (#22180) --- common/djangoapps/terrain/stubs/comments.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/common/djangoapps/terrain/stubs/comments.py b/common/djangoapps/terrain/stubs/comments.py index 702926f919..2f35500dfa 100644 --- a/common/djangoapps/terrain/stubs/comments.py +++ b/common/djangoapps/terrain/stubs/comments.py @@ -5,6 +5,7 @@ Stub implementation of cs_comments_service for acceptance tests from __future__ import absolute_import import re +from collections import OrderedDict import six.moves.urllib.parse # pylint: disable=import-error @@ -18,15 +19,15 @@ class StubCommentsServiceHandler(StubHttpRequestHandler): return six.moves.urllib.parse.parse_qs(six.moves.urllib.parse.urlparse(self.path).query) def do_GET(self): - pattern_handlers = { - "/api/v1/users/(?P\\d+)/active_threads$": self.do_user_profile, - "/api/v1/users/(?P\\d+)$": self.do_user, - "/api/v1/search/threads$": self.do_search_threads, - "/api/v1/threads$": self.do_threads, - "/api/v1/threads/(?P\\w+)$": self.do_thread, - "/api/v1/comments/(?P\\w+)$": self.do_comment, - "/api/v1/(?P\\w+)/threads$": self.do_commentable, - } + pattern_handlers = OrderedDict([ + ("/api/v1/users/(?P\\d+)/active_threads$", self.do_user_profile), + ("/api/v1/users/(?P\\d+)$", self.do_user), + ("/api/v1/search/threads$", self.do_search_threads), + ("/api/v1/threads$", self.do_threads), + ("/api/v1/threads/(?P\\w+)$", self.do_thread), + ("/api/v1/comments/(?P\\w+)$", self.do_comment), + ("/api/v1/(?P\\w+)/threads$", self.do_commentable), + ]) if self.match_pattern(pattern_handlers): return