Skip to content

Commit

Permalink
manual insert query in Reader test
Browse files Browse the repository at this point in the history
  • Loading branch information
arcangelo7 committed Oct 20, 2024
1 parent 19cff20 commit 27bd9a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions oc_ocdm/test/reader/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,29 @@
import os
import unittest

from rdflib import URIRef
from SPARQLWrapper import JSON, SPARQLWrapper

from oc_ocdm.graph import GraphSet
from oc_ocdm.reader import Reader
from rdflib import Graph, URIRef
from SPARQLWrapper import POST, SPARQLWrapper


class TestReader(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.endpoint = 'http://127.0.0.1:8804/sparql'
BASE = os.path.join('oc_ocdm', 'test', 'reader')
file_path = os.path.abspath(os.path.join(BASE, 'br.nt'))

g = Graph()
g.parse(file_path, format='nt')

insert_query = "INSERT DATA { GRAPH <https://w3id.org/oc/meta/> {\n"
for s, p, o in g:
insert_query += f"{s.n3()} {p.n3()} {o.n3()} .\n"
insert_query += "} }"
server = SPARQLWrapper(cls.endpoint)
query = 'LOAD <file:' + os.path.abspath(os.path.join(BASE, f'br.nt')).replace('\\', '/') + '> INTO GRAPH <' + f'https://w3id.org/oc/meta/' + '>'
server.setQuery(query)
server.setMethod(POST)
server.setQuery(insert_query)
server.query()

def test_import_entity_from_triplestore(self):
Expand Down
Binary file modified virtuoso-opensource/database/virtuoso.trx
Binary file not shown.

0 comments on commit 27bd9a1

Please sign in to comment.