Skip to content

Commit

Permalink
Bump coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Van Daele committed Sep 27, 2015
1 parent 9249d4f commit 07173c0
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_functional.py
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'
22 changes: 22 additions & 0 deletions tests/test_general.py
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

0 comments on commit 07173c0

Please sign in to comment.