Skip to content

Commit

Permalink
Adding initial testing for issue ucoProject#423
Browse files Browse the repository at this point in the history
  • Loading branch information
kfairbanks committed Aug 9, 2022
1 parent a278da6 commit b2742c1
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
93 changes: 93 additions & 0 deletions tests/context_builder/action_result_NO_CONTEXT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"@graph": [
{
"@id": "kb:action-1",
"@type": "action:Action",
"rdfs:comment": "This node is some action that has some ObservableObjects as results. By the ontology, the results need to be some UcoObject or subclass of UcoObject. They are serialized here as ObservableObjects, and are redundantly assigned types of some of their superclasses. For completeness-tracking, let the id slug's number be a binary number tracking which superclasses are present, 2^0=core:UcoObject, 2^1=core:Item, 2^2=observable:Observable.",
"action:result": [
{
"@id": "kb:node-0"
},
{
"@id": "kb:node-1"
},
{
"@id": "kb:node-2"
},
{
"@id": "kb:node-3"
},
{
"@id": "kb:node-4"
},
{
"@id": "kb:node-5"
},
{
"@id": "kb:node-6"
},
{
"@id": "kb:node-7"
}
]
},
{
"@id": "kb:node-0",
"@type": "observable:ObservableObject"
},
{
"@id": "kb:node-1",
"@type": [
"core:UcoObject",
"observable:ObservableObject"
]
},
{
"@id": "kb:node-2",
"@type": [
"core:Item",
"observable:ObservableObject"
]
},
{
"@id": "kb:node-3",
"@type": [
"core:UcoObject",
"core:Item",
"observable:ObservableObject"
]
},
{
"@id": "kb:node-4",
"@type": [
"observable:Observable",
"observable:ObservableObject"
]
},
{
"@id": "kb:node-5",
"@type": [
"core:UcoObject",
"observable:Observable",
"observable:ObservableObject"
]
},
{
"@id": "kb:node-6",
"@type": [
"core:Item",
"observable:Observable",
"observable:ObservableObject"
]
},
{
"@id": "kb:node-7",
"@type": [
"core:UcoObject",
"core:Item",
"observable:Observable",
"observable:ObservableObject"
]
}
]
}
29 changes: 29 additions & 0 deletions tests/context_builder/context_tester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!python

import json
import rdflib
import sys
import subprocess

test_file = "action_result_NO_CONTEXT.json"
output_file = "temp_cntxt.json"
# Execute Context builder
cmd = "python ../../src/uco_jsonld_context_builder.py --output " + output_file
print(cmd)
subprocess.run(cmd.split())
with open(output_file, 'r') as file:
tmp_c = json.load(file)
# print(tmp_c)
graph = rdflib.Graph()
graph.parse(test_file, format="json-ld")
graph.serialize("test_out_no_cntxt.json-ld", format="json-ld")
graph2 = rdflib.Graph()
graph2.parse(test_file, format="json-ld", context_data=tmp_c)
graph.serialize("test_out_cntxt.json-ld", context_data=tmp_c, format="json-ld", auto_compact=True)
# graph2.parse("../tests/uco_monolithic.ttl", format="turtle", context_data=tmp_c)
# graph2.parse("../tests/uco_monolithic.ttl", format="turtle")
# graph.serialize("__uco_monolithic.json-ld", context_data=tmp_c, format="json-ld", auto_compact=False)
# graph2.serialize("__uco_monolithic.json-ld", context_data=tmp_c, format="json-ld", auto_compact=True)
#graph2.serialize("__uco_monolithic.json-ld", context_data=tmp_c, format="json-ld", auto_compact=True)
# graph2.serialize("__uco_monolithic.json-ld", format="json-ld", auto_compact=True)
sys.exit()

0 comments on commit b2742c1

Please sign in to comment.