Skip to content

Commit

Permalink
#77 fixed get_by_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
Emrys committed Oct 1, 2020
1 parent 1d14e2d commit b08bf44
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pytest==4.6.9 ; python_version < '3.0'
pytest==5.3.5 ; python_version >= '3.0'
pytest-cov==2.8.1
coveralls==1.11.1
nose == 1.3.7

# Documentation
Sphinx==1.8.5 ; python_version < '3.5'
Expand Down
5 changes: 4 additions & 1 deletion skosprovider_getty/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ def hierarchy_notetypes(list):


def uri_to_id(uri):
return uri.strip('/').rsplit('/', 1)[1]
try:
return uri.strip('/').rsplit('/', 1)[1]
except IndexError:
return uri


def uri_to_graph(uri, **kwargs):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def test_get_by_uri(self):
self.assertEqual(concept['uri'], 'http://vocab.getty.edu/aat/300007466')
self.assertEqual(concept['id'], '300007466')

def test_get_by_uri_invalid(self):
# Default GettyProvider is an AAT provider
concept = GettyProvider({'id': 'AAT'}).get_by_uri('urn:skosprovider:5')
self.assertFalse(concept)

def test_get_by_id_tgn(self):
concept = TGNProvider({'id': 'TGN'}).get_by_id('1000063')
concept = concept.__dict__
Expand Down

0 comments on commit b08bf44

Please sign in to comment.