Skip to content

Commit

Permalink
Merge pull request #71 from OnroerendErfgoed/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
claeyswo authored Dec 7, 2020
2 parents 0b611e6 + 3c85c6b commit 3b95560
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 131 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.8"
env:
- LC_ALL=en_US.utf-8
install:
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.2.0 (07-12-2020)
------------------

- Library update(#69)
- Py3 compatibel maken (#66)

0.1.2 (08-06-2017)
------------------

Expand Down
21 changes: 10 additions & 11 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# RestRegistry documentation build configuration file, created by
# sphinx-quickstart on Wed Aug 20 13:33:02 2014.
Expand Down Expand Up @@ -57,17 +56,17 @@
master_doc = 'index'

# General information about the project.
project = u'UriRegistry'
copyright = u'2014-2015, Onroerend Erfgoed'
project = 'UriRegistry'
copyright = '2014-2020, Onroerend Erfgoed'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.1.0'
version = '0.1.3'
# The full version, including alpha/beta/rc tags.
release = '0.1.1'
release = '0.1.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -210,8 +209,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'UriRegistry.tex', u'UriRegistry Documentation',
u'Onroerend Erfgoed', 'manual'),
('index', 'UriRegistry.tex', 'UriRegistry Documentation',
'Onroerend Erfgoed', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -240,8 +239,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'uriregistry', u'UriRegistry Documentation',
[u'Onroerend Erfgoed'], 1)
('index', 'uriregistry', 'UriRegistry Documentation',
['Onroerend Erfgoed'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -254,8 +253,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'UriRegistry', u'UriRegistry Documentation',
u'Onroerend Erfgoed', 'UriRegistry', "Where's my uri?",
('index', 'UriRegistry', 'UriRegistry Documentation',
'Onroerend Erfgoed', 'UriRegistry', "Where's my uri?",
'Miscellaneous'),
]

Expand Down
18 changes: 9 additions & 9 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
--requirement requirements.txt

# Documentation
Sphinx==1.7.8
Sphinx==3.1.1
sphinxcontrib-httpdomain==1.7.0
sphinxcontrib-plantuml==0.12
sphinxcontrib-plantuml==0.18

waitress==1.1.0
pyramid_debugtoolbar==4.4
waitress==1.4.4
pyramid_debugtoolbar==4.6.1

#testing
pytest==3.7.4
pytest-cov==2.5.1
webtest==2.0.30
httpretty==0.9.5
coveralls==1.5.0
pytest==5.4.3
pytest-cov==2.10.0
webtest==2.0.35
httpretty==1.0.3
coveralls==2.0.0

# Wheel
wheel==0.31.1
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
requests==2.21.0
pyramid==1.10.1
requests==2.25.0
pyramid==1.10.5

PyYAML==3.13
PyYAML==5.3.1

pyramid_urireferencer==0.6.0
pyramid_urireferencer==0.7.0
7 changes: 2 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
]

setup(name='uriregistry',
version='0.1.2',
version='0.2.0',
description='A central URI registry that tracks where a certain URI is being used.',
long_description=README + '\n\n' + CHANGES,
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.8",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ def registryconfig():
cfg = {
'uri_templates': [
{
'match_uri': 'http://id.erfgoed.net/foobar/\d+',
'match_uri': r'http://id.erfgoed.net/foobar/\d+',
'applications': ['http://localhost:5555', 'http://localhost:2222']
}, {
'match_uri': 'http://id.erfgoed.net/bar/\w+',
'match_uri': r'http://id.erfgoed.net/bar/\w+',
'applications': ['http://localhost:5555']
}, {
'match_uri': 'http://id.erfgoed.net/foo/.+',
'match_uri': r'http://id.erfgoed.net/foo/.+',
'applications': ['http://localhost:2222']
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import os

import pytest

from webtest import TestApp


@pytest.fixture()
def app():
settings = {
Expand All @@ -13,6 +13,7 @@ def app():
from uriregistry import main
return TestApp(main({}, **settings))


class TestFunctional:

def test_home(self, app):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_general.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import pytest

import os

from uriregistry import (
_parse_settings,
_load_configuration
)


class TestGeneral:

def test_parse_settings(self):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from uriregistry.models import Application, UriTemplate
from uriregistry.models import UriTemplate


class TestUri:

def test_numeric_matches(self):
u = UriTemplate('http://id.erfgoed.net/foobar/\d+$', [])
u = UriTemplate(r'http://id.erfgoed.net/foobar/\d+$', [])
assert u.matches('http://id.erfgoed.net/foobar/1')
assert u.matches('http://id.erfgoed.net/foobar/12')
assert u.matches('http://id.erfgoed.net/foobar/123456789')
Expand All @@ -14,7 +15,7 @@ def test_numeric_matches(self):
assert not u.matches('http://id.erfgoed.net/foobar/1a')

def test_alphanumeric_matches(self):
u = UriTemplate('http://id.erfgoed.net/foobar/\w+$', [])
u = UriTemplate(r'http://id.erfgoed.net/foobar/\w+$', [])
assert u.matches('http://id.erfgoed.net/foobar/a')
assert u.matches('http://id.erfgoed.net/foobar/at')
assert u.matches('http://id.erfgoed.net/foobar/baz')
Expand Down
27 changes: 7 additions & 20 deletions tests/test_registry.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
import os
import unittest
import pytest

from pyramid import testing
from pyramid.response import Response

from uriregistry import _load_configuration
from uriregistry.registry import (
IUriRegistry,
UriRegistry,
_build_uri_registry,
get_uri_registry
)
from uriregistry.models import Application
from uriregistry.utils import query_application
from uriregistry.views import RegistryView, _get_registry_response

from pyramid_urireferencer.models import RegistryResponse, ApplicationResponse
from uriregistry.registry import IUriRegistry
from uriregistry.registry import UriRegistry
from uriregistry.registry import _build_uri_registry
from uriregistry.registry import get_uri_registry


class TestRegistry:

Expand All @@ -35,13 +21,14 @@ def test_get_applications_alphanumeric_matches(self, uriregistry):
apps = uriregistry.get_applications('http://id.erfgoed.net/foobar/a')
assert len(apps) == 0


class MockRegistry:

def __init__(self, settings=None):

if settings is None:
self.settings = {}
else: # pragma NO COVER
else: # pragma NO COVER
self.settings = settings

self.uri_registry = None
Expand Down
3 changes: 1 addition & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-

from uriregistry.models import Application
from pyramid_urireferencer.models import ApplicationResponse

from uriregistry.utils import query_application


class TestUtils:

def test_get_application_response(self):
Expand Down
22 changes: 14 additions & 8 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest

from pyramid import testing
Expand All @@ -12,6 +11,7 @@
def pyramid_request():
return testing.DummyRequest()


class TestViews:

def test_home(self, pyramid_request):
Expand All @@ -38,25 +38,31 @@ def test_get_references_uri(self, pyramid_request, uriregistry):
assert not res.has_references
assert not res.success


def test_get_registry_response():
from uriregistry.views import _get_registry_response
uri = "http://id.erfgoed.net/foobar/2/"
app_response_success_ref = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", True, True, 2, [])
app_response_success_ref2 = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", True, True, 3, [])
app_response_nosuccess = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", False, None, None, None)
app_response_nosuccess2 = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", False, None, None, None)
app_response_success_noref = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", True, False, None, None)
app_response_success_noref2 = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", True, False, None, None)
app_response_success_ref2 = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", True, True, 3,
[])
app_response_nosuccess = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", False, None, None,
None)
app_response_nosuccess2 = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", False, None, None,
None)
app_response_success_noref = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", True, False,
None, None)
app_response_success_noref2 = ApplicationResponse("app2_name", "http://uri/app2", "http://url/app2", True, False,
None, None)

r = _get_registry_response([app_response_success_ref,app_response_success_ref2], uri)
r = _get_registry_response([app_response_success_ref, app_response_success_ref2], uri)
assert isinstance(r, RegistryResponse)
assert len(r.applications) == 2
assert r.query_uri == uri
assert r.has_references
assert r.success
assert r.count == 5

r = _get_registry_response([app_response_success_ref,app_response_nosuccess], uri)
r = _get_registry_response([app_response_success_ref, app_response_nosuccess], uri)
assert isinstance(r, RegistryResponse)
assert len(r.applications) == 2
assert r.query_uri == uri
Expand Down
Loading

0 comments on commit 3b95560

Please sign in to comment.