Skip to content

Commit

Permalink
Merge e5e9e82 into 1d14e2d
Browse files Browse the repository at this point in the history
  • Loading branch information
roefem committed Oct 2, 2020
2 parents 1d14e2d + e5e9e82 commit fb00fcd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion skosprovider_getty/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_by_uri(self, uri, change_notes=False):

id = uri_to_id(uri)

return self.get_by_id(id, change_notes)
return self.get_by_id(id, change_notes) if 'vocab.getty.edu' in uri else None

def find(self, query, **kwargs):
'''Find concepts that match a certain query.
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
7 changes: 7 additions & 0 deletions tests/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ 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)
concept = GettyProvider({'id': 'AAT'}).get_by_uri('https://id.erfgoed.net/thesauri/materialen/7')
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 fb00fcd

Please sign in to comment.