Skip to content

Commit

Permalink
fixed create_load test, gave up on test_query for now, since it needs…
Browse files Browse the repository at this point in the history
… to have books data already loaded. I think it will become nearly redundant with create_load if I finish loading books in.
  • Loading branch information
kevinschaper committed May 31, 2024
1 parent 59e04ae commit 56179c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tests/test_create_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import requests

from linkml_runtime.dumpers import json_dumper, rdf_dumper
from linkml_runtime.loaders import yaml_loader, csv_loader
from linkml_runtime.loaders import yaml_loader, tsv_loader
from linkml.generators.yamlgen import YAMLGenerator
from linkml_runtime.utils.schemaview import SchemaView

Expand Down Expand Up @@ -47,7 +47,7 @@ def test_create_load(self):
qe.add([a])
results = qe.query(target_class=GeneToDiseaseAssociation)
assert len(results) == 1
container = csv_loader.load(DATA, schemaview=sv, index_slot='associations', target_class=Container)
container = tsv_loader.load(DATA, schemaview=sv, index_slot='associations', target_class=Container)
print(f'ASSOCS={len(container.associations)}')
assert len(container.associations) > 50
qe.add(container.associations)
Expand Down
9 changes: 8 additions & 1 deletion tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
from tests import INPUT_DIR, MODEL_DIR

from linkml_solr import SolrQueryEngine, SolrEndpoint
from linkml_solr.utils.solr_bulkload import bulkload_file

from SPARQLWrapper import SPARQLWrapper, N3
from rdflib import Graph

SCHEMA = os.path.join(MODEL_DIR, 'books.yaml')


@unittest.skip("skipping test_query, since it requires a solr instance already loaded with books")
class QueryTestCase(unittest.TestCase):
"""
This test requires a solr instance running - see the Makefile
Expand All @@ -25,10 +29,13 @@ class QueryTestCase(unittest.TestCase):

def test_query(self):
""" tests querying from and adding to a solr endpoint """

schema = YAMLGenerator(SCHEMA).schema

qe = SolrQueryEngine(schema=schema,
endpoint=SolrEndpoint(url='http://localhost:8983/solr/books'))
qe.load_schema()
gen = qe.load_schema()
bulkload_file(INPUT_DIR + '/books.json', format='json', schema=schema, core='books', base_url='http://localhost:8983/solr')
sq = qe.generate_query(genre_s='fantasy')
print(sq)
print(sq.http_params())
Expand Down

0 comments on commit 56179c5

Please sign in to comment.