Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit c38a7b4

Browse files
committed
Added tests for country redirecting, added a regex char so slashes after country code is handled
1 parent 52ae528 commit c38a7b4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

web/tests/test_site.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,17 @@ def test_unknown_URL(db, client):
66
response = client.get('/bar-foo/')
77

88
assert response.status_code == 404
9+
10+
@pytest.mark.django_db
11+
def test_country_redirect(db, client):
12+
# Test without a slash in the end
13+
response = client.get('/AB')
14+
15+
assert response.status_code == 301
16+
assert response['Location'][-4:] == '/#AB'
17+
18+
# and with one
19+
response = client.get('/AB/')
20+
21+
assert response.status_code == 301
22+
assert response['Location'][-4:] == '/#AB'

web/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
url(r'^scoreboard/$', 'events.scoreboard', name='web.scoreboard'),
2525
url(r'^change_status/(?P<event_id>\d+)/$', 'events.change_status', name='web.change_status'),
2626
url(r'^reject_status/(?P<event_id>\d+)/$', 'events.reject_status', name='web.reject_status'),
27-
url(r'^(?P<country_code>[A-Z][A-Z])$', RedirectView.as_view(url = '/#%(country_code)s')),
27+
url(r'^(?P<country_code>[A-Z][A-Z])/?$', RedirectView.as_view(url = '/#%(country_code)s')),
2828
)

0 commit comments

Comments
 (0)