Skip to content

Commit e02d01f

Browse files
committed
Add unit test for url generation to catch #564
1 parent d2a96ba commit e02d01f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

common/tests/test_helpers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections import OrderedDict
1+
import re
22
from django.conf import settings
33
from django.test import TestCase
44
from common.helpers.caching import is_sitemap_url
@@ -28,12 +28,16 @@ def test_section_path(self):
2828
expected = '/events/test-slug'
2929
self.assertEqual(expected, section_path(FrontEndSection.AboutEvent, {'id': 'test-slug'}))
3030

31-
# TODO: Add test for multiple args
3231
def test_section_path_with_single_arg(self):
3332
expected = '/events/test-slug?a=1'
34-
arg_dict = OrderedDict([('id', 'test-slug'), ('a', '1')])
33+
arg_dict = {'id': 'test-slug', 'a': '1'}
3534
self.assertEqual(expected, section_path(FrontEndSection.AboutEvent, arg_dict))
3635

36+
def test_section_path_with_single_arg(self):
37+
expected_pattern = re.compile(r'/events/test-slug(\?a=1&b=2|\?b=2&a=1)')
38+
arg_dict = {'id': 'test-slug', 'a': '1', 'b': '2'}
39+
self.assertRegexpMatches(section_path(FrontEndSection.AboutEvent, arg_dict), expected_pattern)
40+
3741
def test_section_url(self):
3842
expected = settings.PROTOCOL_DOMAIN + '/events/test-slug'
3943
self.assertEqual(expected, section_url(FrontEndSection.AboutEvent, {'id': 'test-slug'}))

0 commit comments

Comments
 (0)