Skip to content

Commit

Permalink
Make import_provider work with string concept_ids.
Browse files Browse the repository at this point in the history
Issue #97
  • Loading branch information
Wim-De-Clercq committed Mar 20, 2023
1 parent f04140c commit b060c90
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions skosprovider_sqlalchemy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def import_provider(provider, conceptscheme, session):
c = provider.get_by_id(stuff['id'])
if isinstance(c, Concept):
cm = ConceptModel(
concept_id=int(c.id),
concept_id=c.id,
uri=c.uri,
conceptscheme=conceptscheme
)
elif isinstance(c, Collection):
cm = CollectionModel(
concept_id=int(c.id),
concept_id=c.id,
uri=c.uri,
conceptscheme=conceptscheme
)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,23 @@ def test_empty_provider(self):
scheme = self.session.get(ConceptSchemeModel, 68)
assert scheme == cs

def test_string_concept_id_provider(self):
from skosprovider_sqlalchemy.models import (
ConceptScheme as ConceptSchemeModel
)
from skosprovider.providers import DictionaryProvider

p = DictionaryProvider(
{'id': 'EMPTY'}, [{'id': 'manual-1', 'uri': 'urn:x-skosprovider:manual/manual-1'}]
)
cs = self._get_cs()
self.session.add(cs)
import_provider(p, cs, self.session)
scheme = self.session.get(ConceptSchemeModel, 68)
assert scheme == cs
assert len(scheme.concepts) == 1
assert scheme.concepts[0].concept_id == 'manual-1'

def test_menu(self):
from skosprovider_sqlalchemy.models import (
Concept as ConceptModel
Expand Down

0 comments on commit b060c90

Please sign in to comment.