Skip to content

Commit

Permalink
More fixes and tests for source notes. Refs #199
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Van Daele committed Dec 8, 2015
1 parent ae9a3e3 commit 3953e1e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
10 changes: 9 additions & 1 deletion atramhasis/utils.py
Expand Up @@ -5,7 +5,7 @@
from collections import deque
from pyramid.httpexceptions import HTTPMethodNotAllowed

from skosprovider.skos import Concept, Collection, Label, Note, ConceptScheme
from skosprovider.skos import Concept, Collection, Label, Note, Source, ConceptScheme
from skosprovider_sqlalchemy.providers import SQLAlchemyProvider


Expand All @@ -28,6 +28,10 @@ def from_thing(thing):
Label(l.label, l.labeltype_id, l.language_id)
for l in thing.labels
],
sources=[
Source(s.citation)
for s in thing.sources
],
members=[member.concept_id for member in thing.members] if hasattr(thing, 'members') else [],
member_of=[c.concept_id for c in thing.member_of],
superordinates=[broader_concept.concept_id for broader_concept in thing.broader_concepts]
Expand All @@ -51,6 +55,10 @@ def from_thing(thing):
Note(n.note, n.notetype_id, n.language_id)
for n in thing.notes
],
sources=[
Source(s.citation)
for s in thing.sources
],
broader=[c.concept_id for c in thing.broader_concepts],
narrower=[c.concept_id for c in thing.narrower_concepts],
related=[c.concept_id for c in thing.related_concepts],
Expand Down
7 changes: 6 additions & 1 deletion tests/test_functional.py
Expand Up @@ -47,7 +47,12 @@
"label": "The Larch"
}
],
"notes": []
"notes": [],
"sources": [
{
"citation": "Python, M.: Episode Three: How to recognise different types of trees from quite a long way away."
}
]
}

json_value_relations = {
Expand Down
13 changes: 12 additions & 1 deletion tests/test_utils.py
Expand Up @@ -3,7 +3,12 @@

from pyramid.httpexceptions import HTTPMethodNotAllowed
from skosprovider.providers import DictionaryProvider
from skosprovider_sqlalchemy.models import Concept, Collection, Note, Label, ConceptScheme, Match, MatchType
from skosprovider_sqlalchemy.models import (
Concept, Collection,
Note, Label, Source,
ConceptScheme,
Match, MatchType
)
from skosprovider_sqlalchemy.providers import SQLAlchemyProvider
from skosprovider.skos import(
Concept as SkosConcept,
Expand Down Expand Up @@ -59,6 +64,11 @@ def setUp(self):
labels.append(label3)
self.concept.labels = labels

sources = []
source = Source(citation='Kinsella S. & Carlisle P. 2015: Alice.')
sources.append(source)
self.concept.sources = sources

matches = []
match1 = Match()
match1.uri ='urn:test'
Expand Down Expand Up @@ -86,6 +96,7 @@ def test_thing_to_concept(self):
self.assertEqual(skosconcept.id, 101)
self.assertEqual(len(skosconcept.labels), 3)
self.assertEqual(len(skosconcept.notes), 2)
self.assertEqual(len(skosconcept.sources), 1)
self.assertEqual(skosconcept.uri, 'urn:x-atramhasis-demo:TREES:101')

def test_thing_to_collection(self):
Expand Down

0 comments on commit 3953e1e

Please sign in to comment.