Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1419] Better status for when no param supplied. Added test.
- Loading branch information
David Read
authored and
nigelb
committed
Jun 26, 2014
1 parent
4bd1f10
commit 18eaeea
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from nose.tools import assert_equal | ||
from pylons.test import pylonsapp | ||
import paste.fixture | ||
|
||
import routes.url_for as url_for | ||
|
||
|
||
# This is stolen from the old tests and should probably go in __init__.py | ||
# if it is what we want. | ||
class WsgiAppCase(object): | ||
wsgiapp = pylonsapp | ||
assert wsgiapp, 'You need to run nose with --with-pylons' | ||
# Either that, or this file got imported somehow before the tests started | ||
# running, meaning the pylonsapp wasn't setup yet (which is done in | ||
# pylons.test.py:begin()) | ||
app = paste.fixture.TestApp(wsgiapp) | ||
|
||
|
||
class TestUtil(WsgiAppCase): | ||
def test_redirect_ok(self): | ||
response = self.app.get( | ||
url=url_for(controller='util', action='redirect'), | ||
params={'url': '/dataset'}, | ||
status=302, | ||
) | ||
assert_equal(response.header_dict.get('Location'), | ||
'http://localhost/dataset') | ||
|
||
def test_redirect_external(self): | ||
response = self.app.get( | ||
url=url_for(controller='util', action='redirect'), | ||
params={'url': 'http://nastysite.com'}, | ||
status=403, | ||
) | ||
|
||
def test_redirect_no_params(self): | ||
response = self.app.get( | ||
url=url_for(controller='util', action='redirect'), | ||
params={}, | ||
status=400, | ||
) | ||
|
||
def test_redirect_no_params_2(self): | ||
response = self.app.get( | ||
url=url_for(controller='util', action='redirect'), | ||
params={'url': ''}, | ||
status=400, | ||
) |