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

Added tests for country redirecting, fixed regex for same #368

Merged
merged 1 commit into from
Oct 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions web/tests/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,17 @@ def test_unknown_URL(db, client):
response = client.get('/bar-foo/')

assert response.status_code == 404

@pytest.mark.django_db
def test_country_redirect(db, client):
# Test without a slash in the end
response = client.get('/AB')

assert response.status_code == 301
assert response['Location'][-4:] == '/#AB'

# and with one
response = client.get('/AB/')

assert response.status_code == 301
assert response['Location'][-4:] == '/#AB'
2 changes: 1 addition & 1 deletion web/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
url(r'^scoreboard/$', 'events.scoreboard', name='web.scoreboard'),
url(r'^change_status/(?P<event_id>\d+)/$', 'events.change_status', name='web.change_status'),
url(r'^reject_status/(?P<event_id>\d+)/$', 'events.reject_status', name='web.reject_status'),
url(r'^(?P<country_code>[A-Z][A-Z])$', RedirectView.as_view(url = '/#%(country_code)s')),
url(r'^(?P<country_code>[A-Z][A-Z])/?$', RedirectView.as_view(url = '/#%(country_code)s')),
)