Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Jul 30, 2021
1 parent 159af39 commit 100357f
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/inputs/books.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
id,book_category,name,price,inStock,author,series_t,sequence_i,genre_s,yesno,blah_b
0553573403,book|game,A Game of Thrones,7.99,true,George R.R. Martin,"A Song of Ice and Fire",1,fantasy,true,false
0553579908,book,A Clash of Kings,7.99,true,George R.R. Martin,"A Song of Ice and Fire",2,fantasy,true,false
055357342X,book,A Storm of Swords,7.99,true,George R.R. Martin,"A Song of Ice and Fire",3,fantasy,true,false
0553293354,book,Foundation,7.99,true,Isaac Asimov,Foundation Novels,1,scifi,true,false
0812521390,book,The Black Company,6.99,false,Glen Cook,The Chronicles of The Black Company,1,fantasy,true,false
0812550706,book,Ender's Game,6.99,true,Orson Scott Card,Ender,1,scifi,true,false
0441385532,book,Jhereg,7.95,false,Steven Brust,Vlad Taltos,1,fantasy,true,false
0380014300,book,Nine Princes In Amber,6.99,true,Roger Zelazny,the Chronicles of Amber,1,fantasy,true,false
0805080481,book,The Book of Three,5.99,true,Lloyd Alexander,The Chronicles of Prydain,1,fantasy,true,false
080508049X,book|film,The Black Cauldron,5.99,true,Lloyd Alexander,The Chronicles of Prydain,2,fantasy,false,true
123,book,Consider Phlebas,7.99,true,Ian M Banks,"",1,scifi,true,false
4 changes: 4 additions & 0 deletions tests/inputs/books.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[{"id": "X:1", "name": "mytestname"}]
[{"id": "X:2", "name": "deep",
"xyz": 1
}]
13 changes: 13 additions & 0 deletions tests/inputs/books.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
id book_category name price inStock author series_t sequence_i genre_s yesno blah_b
0553573403 book|game A Game of Thrones 7.99 true George R.R. Martin A Song of Ice and Fire 1 fantasy true false
0553579908 book A Clash of Kings 7.99 true George R.R. Martin A Song of Ice and Fire 2 fantasy true false
055357342X book A Storm of Swords 7.99 true George R.R. Martin A Song of Ice and Fire 3 fantasy true false
0553293354 book Foundation 7.99 true Isaac Asimov Foundation Novels 1 scifi true false
0812521390 book The Black Company 6.99 false Glen Cook The Chronicles of The Black Company 1 fantasy true false
0812550706 book Ender's Game 6.99 true Orson Scott Card Ender 1 scifi true false
0441385532 book Jhereg 7.95 false Steven Brust Vlad Taltos 1 fantasy true false
0380014300 book Nine Princes In Amber 6.99 true Roger Zelazny the Chronicles of Amber 1 fantasy true false
0805080481 book The Book of Three 5.99 true Lloyd Alexander The Chronicles of Prydain 1 fantasy true false
080508049X book|film The Black Cauldron 5.99 true Lloyd Alexander The Chronicles of Prydain 2 fantasy false true
123 book Consider Phlebas 7.99 true Ian M Banks 1 scifi true false
456 book Warlord of the Air 5.99 true Michael Moorcock Oswald Bastable Trilogy 1 steambunk true false
12 changes: 12 additions & 0 deletions tests/inputs/books2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
id,book_category,name,price,inStock,author,series,sequence,genre,yesno,blah
0553573403,book|game,A Game of Thrones,7.99,true,George R.R. Martin,"A Song of Ice and Fire",1,fantasy,true,false
0553579908,book,A Clash of Kings,7.99,true,George R.R. Martin,"A Song of Ice and Fire",2,fantasy,true,false
055357342X,book,A Storm of Swords,7.99,true,George R.R. Martin,"A Song of Ice and Fire",3,fantasy,true,false
0553293354,book,Foundation,7.99,true,Isaac Asimov,Foundation Novels,1,scifi,true,false
0812521390,book,The Black Company,6.99,false,Glen Cook,The Chronicles of The Black Company,1,fantasy,true,false
0812550706,book,Ender's Game,6.99,true,Orson Scott Card,Ender,1,scifi,true,false
0441385532,book,Jhereg,7.95,false,Steven Brust,Vlad Taltos,1,fantasy,true,false
0380014300,book,Nine Princes In Amber,6.99,true,Roger Zelazny,the Chronicles of Amber,1,fantasy,true,false
0805080481,book,The Book of Three,5.99,true,Lloyd Alexander,The Chronicles of Prydain,1,fantasy,true,false
080508049X,book|film,The Black Cauldron,5.99,true,Lloyd Alexander,The Chronicles of Prydain,2,fantasy,false,true
123,book,Consider Phlebas,7.99,true,Ian M Banks,"",1,scifi,true,false
73 changes: 73 additions & 0 deletions tests/inputs/books_normalized_01.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
all_book_series:
- id: S001
name: Lord of the Rings
genres:
- fantasy
creator:
name: JRR Tolkein
from_country: England
books:
- id: S001.1
name: Fellowship of the Ring
price: 5.99
summary: Hobbits
- id: S001.2
name: The Two Towers
price: 5.99
summary: More hobbits
- id: S001.3
name: Return of the King
price: 6.99
summary: Yet more hobbits
- id: S002
name: The Culture Series
genres:
- scifi
creator:
name: Ian M Banks
from_country: Scotland
books:
- id: S002.1
name: Consider Phlebas
price: 5.99
- id: S002.2
name: Player of Games
price: 5.99
- id: S003
name: Book of the New Sun
genres:
- scifi
- fantasy
creator:
name: Gene Wolfe
from_country: USA
genres:
- scifi
- fantasy
books:
- id: S003.1
name: Shadow of the Torturer
# deliberately omit price information
- id: S003.2
name: Claw of the Conciliator
price: 6.99
- id: S004
name: Example with single book
creator:
name: Ms Writer
from_country: USA
genres:
- romance
books:
- id: S004.1
name: Blah
- id: S005
name: Example with no books
creator:
name: Mr Unproductive
from_country: USA
genres:
- romance
- scifi
- fantasy

84 changes: 84 additions & 0 deletions tests/inputs/books_normalized_02.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
all_book_series:
- id: S001
name: Lord of the Rings
genres:
- fantasy
creator:
name: JRR Tolkein
from_country: England
books:
- id: S001.1
name: Fellowship of the Ring
price: 5.99
summary: Hobbits
genres:
- fantasy
reviews:
- creator:
name: Alexa Fan
rating: 5
review_text: loved it
- creator:
name: Bob Hater
rating: 0
review_text: too many hobbits
- id: S001.2
name: The Two Towers
price: 5.99
summary: More hobbits
- id: S001.3
name: Return of the King
price: 6.99
summary: Yet more hobbits
- id: S002
name: The Culture Series
genres:
- scifi
creator:
name: Ian M Banks
from_country: Scotland
books:
- id: S002.1
name: Consider Phlebas
price: 5.99
- id: S002.2
name: Player of Games
price: 5.99
- id: S003
name: Book of the New Sun
genres:
- scifi
- fantasy
creator:
name: Gene Wolfe
from_country: USA
genres:
- scifi
- fantasy
books:
- id: S003.1
name: Shadow of the Torturer
# deliberately omit price information
- id: S003.2
name: Claw of the Conciliator
price: 6.99
- id: S004
name: Example with single book
creator:
name: Ms Writer
from_country: USA
genres:
- romance
books:
- id: S004.1
name: Blah
- id: S005
name: Example with no books
creator:
name: Mr Unproductive
from_country: USA
genres:
- romance
- scifi
- fantasy

25 changes: 25 additions & 0 deletions tests/inputs/kitchen_sink_inst_01.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
persons:
- id: P:001
name: fred bloggs
age_in_years: 33
- id: P:002
name: joe schmoe
has_employment_history:
- employed_at: ROR:1
started_at_time: 2019-01-01
is_current: true
has_familial_relationships:
- related_to: P:001
type: SIBLING_OF
has_medical_history:
- started_at_time: 2019-01-01
addresses:
- street: 1 foo street
city: foo city
companies:
- id: ROR:1
name: foo
activities:
- id: A:1
started_at_time: 2019-01-01
was_associated_with: Agent:987
44 changes: 44 additions & 0 deletions tests/test_amigo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import unittest

from linkml_runtime.dumpers import json_dumper, rdf_dumper
from linkml_runtime.loaders import yaml_loader
from linkml.generators.yamlgen import YAMLGenerator
from tests.test_models.amigo import *
import tests.test_models.amigo as amigo

from tests import INPUT_DIR, MODEL_DIR

from linkml_solr import SolrQueryEngine, SolrEndpoint
from SPARQLWrapper import SPARQLWrapper, N3
from rdflib import Graph

DATA = os.path.join(INPUT_DIR, 'kitchen_sink_inst_01.yaml')
CONTEXT = os.path.join(MODEL_DIR, 'kitchen_sink.context.jsonld')
SCHEMA = os.path.join(MODEL_DIR, 'amigo.yaml')

class QueryTestCase(unittest.TestCase):

def test_query(self):
""" solr """
# TODO: use mock server
schema = YAMLGenerator(SCHEMA).schema
qe = SolrQueryEngine(schema=schema,
discriminator_field=amigo.slots.document_category.name,
endpoint=SolrEndpoint(url='http://golr.geneontology.org/solr/'))

sq = qe.generate_query(document_category=OntologyClass.class_name, synonym='apoptosis')
print(sq)
print(sq.http_params())

result = qe.search(target_class=OntologyClass, isa_partof_closure='GO:0031965') ## nuclear membrane
#print(f'Result={result}')
for oc in result.items:
oc: OntologyClass
print(f'Term: {oc.id} {oc.annotation_class_label}')




if __name__ == '__main__':
unittest.main()

0 comments on commit 100357f

Please sign in to comment.