Skip to content

Commit

Permalink
Fix #24
Browse files Browse the repository at this point in the history
  • Loading branch information
koenedaele committed May 8, 2017
1 parent 94a54a7 commit c266c96
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 7 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.7.1 (2017-??-??)
------------------

- Return an HTTP 404 response when a conceptscheme could not be found. (#24)


0.7.0 (2016-08-11)
------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# The short X.Y version.
version = '0.7'
# The full version, including alpha/beta/rc tags.
release = '0.7.0'
release = '0.7.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 6 additions & 0 deletions pyramid_skosprovider/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ def get_concept(self):
scheme_id = self.request.matchdict['scheme_id']
concept_id = self.request.matchdict['c_id']
provider = self.skos_registry.get_provider(scheme_id)
if not provider:
return HTTPNotFound()
concept = provider.get_by_id(concept_id)
if not concept:
return HTTPNotFound()
Expand All @@ -230,6 +232,8 @@ def get_concept_display_children(self):
scheme_id = self.request.matchdict['scheme_id']
concept_id = self.request.matchdict['c_id']
provider = self.skos_registry.get_provider(scheme_id)
if not provider:
return HTTPNotFound()
language = self.request.params.get('language', self.request.locale_name)
children = provider.get_children_display(concept_id, language=language)
if children is False:
Expand All @@ -241,6 +245,8 @@ def get_expand(self):
scheme_id = self.request.matchdict['scheme_id']
concept_id = self.request.matchdict['c_id']
provider = self.skos_registry.get_provider(scheme_id)
if not provider:
return HTTPNotFound()
expanded = provider.expand(concept_id)
if not expanded:
return HTTPNotFound()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

setup(
name='pyramid_skosprovider',
version='0.7.0',
version='0.7.1',
license='MIT',
description='Integration of skosprovider in pyramid',
long_description=README + '\n\n' + CHANGES,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import json

import unittest
from mock import Mock
from unittest.mock import Mock


class TestRenderers(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import json

import unittest
from mock import Mock
from unittest.mock import Mock

class TestQueryBuilder:

Expand Down
32 changes: 31 additions & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,16 @@ def test_get_unexsisting_concept(self):
concept = pv.get_concept()
self.assertIsInstance(concept, HTTPNotFound)

def test_get_concept_unexisting_conceptscheme(self):
request = self._get_dummy_request()
request.matchdict = {
'scheme_id': 'PARROTS',
'c_id': 1
}
pv = self._get_provider_view(request)
concept = pv.get_concept()
self.assertIsInstance(concept, HTTPNotFound)

def test_get_concept_display_children(self):
request = self._get_dummy_request()
request.matchdict = {
Expand Down Expand Up @@ -473,6 +483,16 @@ def test_get_unexsisting_concept_display_children(self):
concept = pv.get_concept_display_children()
self.assertIsInstance(concept, HTTPNotFound)

def test_get_concept_display_children_unexisting_conceptscheme(self):
request = self._get_dummy_request()
request.matchdict = {
'scheme_id': 'PARROTS',
'c_id': 1
}
pv = self._get_provider_view(request)
concept = pv.get_concept_display_children()
self.assertIsInstance(concept, HTTPNotFound)

def test_get_concept_expand(self):
request = self._get_dummy_request()
request.matchdict = {
Expand Down Expand Up @@ -507,13 +527,23 @@ def test_get_expand_no_resource(self):
expanded = pv.get_expand()
self.assertIsInstance(expanded, HTTPNotFound)

def test_get_top_concepts_unexisting_conceptscheme(self):
def test_get_expand_unexisting_conceptscheme(self):
request = self._get_dummy_request()
request.matchdict = {'scheme_id': 'PARROTS'}
pv = self._get_provider_view(request)
tc = pv.get_conceptscheme_top_concepts()
self.assertIsInstance(tc, HTTPNotFound)

def test_get_top_concepts_unexisting_conceptscheme(self):
request = self._get_dummy_request()
request.matchdict = {
'scheme_id': 'PARROTS',
'c_id': 1
}
pv = self._get_provider_view(request)
expanded = pv.get_expand()
self.assertIsInstance(expanded, HTTPNotFound)

def test_get_top_concepts(self):
request = self._get_dummy_request()
request.matchdict = {'scheme_id': 'TREES'}
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist = py27,py33,py34,py35,cover
[testenv]
commands =
python setup.py develop
pip install -r requirements.txt # Fix versions
pip install -r requirements-dev.txt # Fix versions
py.test
deps =
pytest
Expand All @@ -15,7 +15,7 @@ basepython =
python2.7
commands =
python setup.py develop
pip install -r requirements.txt # Fix versions
pip install -r requirements-dev.txt # Fix versions
py.test --cov pyramid_skosprovider --cov-report term-missing tests
deps =
webtest
Expand Down

0 comments on commit c266c96

Please sign in to comment.