Skip to content

Commit

Permalink
Add get_vocabulary_uri method. Refs #86
Browse files Browse the repository at this point in the history
  • Loading branch information
koenedaele committed Oct 31, 2023
1 parent cb13af5 commit 856f1be
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ python:
- 3.8
- 3.9
- 3.10
- 3.11
install:
- pip install -U setuptools
- pip install -r requirements.txt #fix versions
- pip install -r requirements-dev.txt #fix versions
- python setup.py develop
- pip install pytest pytest-cov coveralls #install test deps
script:
- py.test --cov skosprovider_heritagedata --cov-report term-missing tests
after_success:
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
]

requires = [
'skosprovider>=0.6.0',
'skosprovider>=1.1.0',
'requests',
'rdflib'
]

setup(
name='skosprovider_heritagedata',
version='1.1.0',
version='1.2.0',
description='Skosprovider implementation of the heritagedata.org Vocabularies',
long_description=README,
packages=packages,
Expand All @@ -36,10 +36,10 @@
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
author='Flanders Heritage Agency',
author_email='[email protected]',
url='https://github.com/OnroerendErfgoed/skosprovider_heritagedata',
keywords='heritagedata.org skos skosprovider thesauri vocabularies',
test_suite='nose.collector'
)
13 changes: 11 additions & 2 deletions skosprovider_heritagedata/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,26 @@ def __init__(self, metadata, **kwargs):
self.base_scheme_uri = 'http://purl.org/heritagedata/schemes'
self.scheme_id = 'eh_period'
self.scheme_uri = self.base_scheme_uri + "/" + self.scheme_id
if not 'uri' in self.metadata:
self.metadata['uri'] = self.scheme_uri

if 'service_scheme_uri' in kwargs:
self.service_scheme_uri = kwargs['service_scheme_uri'].strip('/')
else:
self.service_scheme_uri = "http://heritagedata.org/live/services"
self.session = kwargs.get('session', requests.Session())

if 'concept_scheme' in kwargs:
self._conceptscheme = kwargs.get('concept_scheme')
else:
self._conceptscheme = None

@property
def concept_scheme(self):
return self._get_concept_scheme()

if self._conceptscheme is None:
self._conceptscheme = self._get_concept_scheme()
return self._conceptscheme

def _get_concept_scheme(self):
return conceptscheme_from_uri(
self.scheme_uri,
Expand Down
28 changes: 28 additions & 0 deletions tests/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

class HeritagedataProviderTests(unittest.TestCase):

def _get_provider(self):
return HeritagedataProvider(
{'id': 'Heritagedata'},
service_scheme_uri='http://heritagedata.org/live/services/'
)

def test_set_custom_session(self):
import requests
sess = requests.Session()
Expand All @@ -19,6 +25,28 @@ def test_set_custom_session(self):
)
self.assertEqual(sess, provider.session)

def test_get_default_vocabulary_uri(self):
provider = self._get_provider()
assert 'http://purl.org/heritagedata/schemes/eh_period' == provider.get_vocabulary_uri()

def test_get_custom_vocabulary_uri(self):
provider = HeritagedataProvider(
{'id': 'ScAPA'},
service_scheme_uri='http://heritagedata.org/live/services/',
scheme_uri= 'http://purl.org/heritagedata/schemes/scapa'
)
assert 'http://purl.org/heritagedata/schemes/scapa' == provider.get_vocabulary_uri()

def test_get_vocabulary_uri_does_not_load_cs(self):
provider = HeritagedataProvider(
{'id': 'ScAPA'},
service_scheme_uri='http://heritagedata.org/live/services/',
scheme_uri= 'http://purl.org/heritagedata/schemes/scapa'
)
assert provider._conceptscheme is None
assert 'http://purl.org/heritagedata/schemes/scapa' == provider.get_vocabulary_uri()
assert provider._conceptscheme is None

def test_default_provider(self):
provider = HeritagedataProvider({'id': 'Heritagedata'},service_scheme_uri='http://heritagedata.org/live/services/')
self.assertEqual(provider.base_scheme_uri, 'http://purl.org/heritagedata/schemes')
Expand Down

0 comments on commit 856f1be

Please sign in to comment.