-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Koen Van Daele
committed
Sep 27, 2015
1 parent
9249d4f
commit 07173c0
Showing
2 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
|
||
import pytest | ||
|
||
from webtest import TestApp | ||
|
||
@pytest.fixture() | ||
def app(): | ||
settings = { | ||
'urihandler.config': os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test.yaml') | ||
} | ||
from urihandler import main | ||
return TestApp(main({}, **settings)) | ||
|
||
class TestFunctional: | ||
|
||
def test_redirect(self, app): | ||
res = app.get('/foobar/18', status=303) | ||
assert res.status == '303 See Other' | ||
|
||
def test_redirect_no_match(self, app): | ||
res = app.get('/test', status=404) | ||
assert res.status == '404 Not Found' | ||
|
||
def test_handle(self, app): | ||
res = app.get('/handle?uri=http://localhost/foobar/18', status=303) | ||
assert res.status == '303 See Other' | ||
|
||
def test_handle_no_match(self, app): | ||
res = app.get('/handle?uri=http://id.erfgoed.net/foo/1', status=404) | ||
assert res.status == '404 Not Found' | ||
|
||
def test_handle_no_uri(self, app): | ||
res = app.get('/handle?url=http://id.erfgoed.net/foo/1', status=400) | ||
assert res.status == '400 Bad Request' |
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,22 @@ | ||
import pytest | ||
|
||
import os | ||
|
||
from urihandler import ( | ||
_parse_settings, | ||
_load_configuration | ||
) | ||
|
||
class TestGeneral: | ||
|
||
def test_parse_settings(self): | ||
settings = { | ||
'urihandler.config': os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test.yaml') | ||
} | ||
args = _parse_settings(settings) | ||
assert 'config' in args | ||
assert args['config'] == os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test.yaml') | ||
|
||
def test_load_configuration(self): | ||
cfg = _load_configuration(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test.yaml')) | ||
assert 'uris' in cfg |