-
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.
Merge pull request #55 from OnroerendErfgoed/develop
Develop
- Loading branch information
Showing
14 changed files
with
187 additions
and
175 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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.4" | ||
- "3.5" | ||
- "3.8" | ||
env: | ||
- LC_ALL=en_US.utf-8 | ||
install: | ||
|
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
0.4.0 (07-12-2020) | ||
------------------ | ||
|
||
- Py3 migratie (#53) | ||
|
||
0.3.0 (12-04-2016) | ||
------------------ | ||
|
||
|
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 |
---|---|---|
@@ -1,18 +1,14 @@ | ||
# Runtime requirements | ||
--requirement requirements.txt | ||
|
||
# Documentation | ||
Sphinx==1.7.1 | ||
sphinxcontrib-httpdomain==1.6.1 | ||
|
||
waitress==1.1.0 | ||
pyramid_debugtoolbar==4.4 | ||
waitress==1.4.4 | ||
pyramid_debugtoolbar==4.9 | ||
|
||
#testing | ||
pytest==3.4.2 | ||
pytest-cov==2.5.1 | ||
webtest==2.0.29 | ||
coveralls==1.3.0 | ||
pytest==6.1.2 | ||
pytest-cov==2.10.1 | ||
webtest==2.0.35 | ||
coveralls==2.2.0 | ||
|
||
# Wheel | ||
wheel==0.30.0 | ||
wheel==0.36.1 |
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
pyramid==1.9.2 | ||
|
||
PyYAML==3.13 | ||
pyramid==1.10.5 | ||
PyYAML==5.3.1 |
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 |
---|---|---|
@@ -1,77 +1,79 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
import json | ||
|
||
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') | ||
"urihandler.config": os.path.join( | ||
os.path.dirname(os.path.realpath(__file__)), "test.yaml" | ||
) | ||
} | ||
from urihandler import main | ||
|
||
return TestApp(main({}, **settings)) | ||
|
||
class TestFunctional: | ||
|
||
class TestFunctional: | ||
def test_redirect(self, app): | ||
res = app.get('/foobar/18', status=303) | ||
assert res.status == '303 See Other' | ||
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' | ||
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' | ||
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' | ||
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' | ||
res = app.get("/handle?url=http://id.erfgoed.net/foo/1", status=400) | ||
assert res.status == "400 Bad Request" | ||
|
||
def test_uris(self, app): | ||
res = app.get('/uris?uri=http://localhost/foobar/18') | ||
assert res.status == '200 OK' | ||
assert 'application/json' in res.headers['Content-Type'] | ||
data = json.loads(res.body.decode('utf-8')) | ||
assert data['uri'] == 'http://localhost/foobar/18' | ||
assert data['location'] == 'http://localhost:5555/foobar/18' | ||
res = app.get("/uris?uri=http://localhost/foobar/18") | ||
assert res.status == "200 OK" | ||
assert "application/json" in res.headers["Content-Type"] | ||
data = json.loads(res.body.decode("utf-8")) | ||
assert data["uri"] == "http://localhost/foobar/18" | ||
assert data["location"] == "http://localhost:5555/foobar/18" | ||
|
||
def test_uris_no_match(self, app): | ||
res = app.get('/uris?uri=http://id.erfgoed.net/foo/1') | ||
assert res.status == '200 OK' | ||
assert 'application/json' in res.headers['Content-Type'] | ||
data = json.loads(res.body.decode('utf-8')) | ||
assert data['uri'] == 'http://id.erfgoed.net/foo/1' | ||
assert data['location'] is None | ||
assert not data['success'] | ||
res = app.get("/uris?uri=http://id.erfgoed.net/foo/1") | ||
assert res.status == "200 OK" | ||
assert "application/json" in res.headers["Content-Type"] | ||
data = json.loads(res.body.decode("utf-8")) | ||
assert data["uri"] == "http://id.erfgoed.net/foo/1" | ||
assert data["location"] is None | ||
assert not data["success"] | ||
|
||
def test_uris_no_uri(self, app): | ||
res = app.get('/uris?url=http://localhost/foobar/18', status=400) | ||
assert res.status == '400 Bad Request' | ||
res = app.get("/uris?url=http://localhost/foobar/18", status=400) | ||
assert res.status == "400 Bad Request" | ||
|
||
def test_uris_two_parameters(self, app): | ||
res = app.get('/uris?uri=urn:x-barbar:area:51') | ||
assert res.status == '200 OK' | ||
assert 'application/json' in res.headers['Content-Type'] | ||
data = json.loads(res.body.decode('utf-8')) | ||
assert data['uri'] == 'urn:x-barbar:area:51' | ||
assert data['location'] == 'http://localhost:2222/area/51' | ||
res = app.get("/uris?uri=urn:x-barbar:area:51") | ||
assert res.status == "200 OK" | ||
assert "application/json" in res.headers["Content-Type"] | ||
data = json.loads(res.body.decode("utf-8")) | ||
assert data["uri"] == "urn:x-barbar:area:51" | ||
assert data["location"] == "http://localhost:2222/area/51" | ||
|
||
def test_uris_caching(self, app): | ||
res = app.get('/uris?uri=http://localhost/foobar/18') | ||
assert 'Cache-Control' in res.headers | ||
assert 'ETag' in res.headers | ||
etag = res.headers['ETag'] | ||
res = app.get("/uris?uri=http://localhost/foobar/18") | ||
assert "Cache-Control" in res.headers | ||
assert "ETag" in res.headers | ||
etag = res.headers["ETag"] | ||
res2 = app.get( | ||
'/uris?uri=http://localhost/foobar/18', | ||
headers={'If-None-Match': etag} | ||
"/uris?uri=http://localhost/foobar/18", headers={"If-None-Match": etag} | ||
) | ||
assert res2.status == '304 Not Modified' | ||
assert res2.status == "304 Not Modified" |
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 |
---|---|---|
@@ -1,22 +1,26 @@ | ||
import pytest | ||
|
||
import os | ||
|
||
from urihandler import ( | ||
_parse_settings, | ||
_load_configuration | ||
) | ||
|
||
class TestGeneral: | ||
|
||
class TestGeneral: | ||
def test_parse_settings(self): | ||
settings = { | ||
'urihandler.config': os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test.yaml') | ||
"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') | ||
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 | ||
cfg = _load_configuration( | ||
os.path.join(os.path.dirname(os.path.realpath(__file__)), "test.yaml") | ||
) | ||
assert "uris" in cfg |
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
Oops, something went wrong.