@@ -166,6 +166,91 @@ def test_log(docker_url):
166166 assert log [0 ]['@type' ] == 'InitialCommit'
167167
168168
169+ def test_get_triples (docker_url ):
170+ client = Client (docker_url , user_agent = test_user_agent , team = "admin" )
171+ client .connect ()
172+ db_name = "testDB" + str (random ())
173+ client .create_database (db_name , team = "admin" )
174+ client .connect (db = db_name )
175+ # Add a philosopher schema
176+ schema = {"@type" : "Class" ,
177+ "@id" : "Philosopher" ,
178+ "name" : "xsd:string"
179+ }
180+ # Add schema and Socrates
181+ client .insert_document (schema , graph_type = "schema" )
182+ schema_triples = client .get_triples (graph_type = 'schema' )
183+ assert "<schema#Philosopher>\n a sys:Class ;\n <schema#name> xsd:string ." in schema_triples
184+
185+
186+ def test_update_triples (docker_url ):
187+ ttl = """
188+ @base <terminusdb:///schema#> .
189+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
190+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
191+ @prefix woql: <http://terminusdb.com/schema/woql#> .
192+ @prefix json: <http://terminusdb.com/schema/json#> .
193+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
194+ @prefix xdd: <http://terminusdb.com/schema/xdd#> .
195+ @prefix vio: <http://terminusdb.com/schema/vio#> .
196+ @prefix sys: <http://terminusdb.com/schema/sys#> .
197+ @prefix api: <http://terminusdb.com/schema/api#> .
198+ @prefix owl: <http://www.w3.org/2002/07/owl#> .
199+ @prefix doc: <data/> .
200+
201+ <schema#Philosopher>
202+ a sys:Class ;
203+ <schema#name> xsd:string .
204+
205+ <terminusdb://context>
206+ a sys:Context ;
207+ sys:base "terminusdb:///data/"^^xsd:string ;
208+ sys:schema "terminusdb:///schema#"^^xsd:string .
209+ """
210+ client = Client (docker_url , user_agent = test_user_agent , team = "admin" )
211+ client .connect ()
212+ db_name = "testDB" + str (random ())
213+ client .create_database (db_name , team = "admin" )
214+ client .connect (db = db_name )
215+ client .update_triples (graph_type = 'schema' , content = ttl , commit_msg = "Update triples" )
216+ client .insert_document ({"name" : "Socrates" })
217+ assert len (list (client .get_all_documents ())) == 1
218+
219+
220+ def test_insert_triples (docker_url ):
221+ ttl = """
222+ @base <terminusdb:///schema#> .
223+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
224+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
225+ @prefix woql: <http://terminusdb.com/schema/woql#> .
226+ @prefix json: <http://terminusdb.com/schema/json#> .
227+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
228+ @prefix xdd: <http://terminusdb.com/schema/xdd#> .
229+ @prefix vio: <http://terminusdb.com/schema/vio#> .
230+ @prefix sys: <http://terminusdb.com/schema/sys#> .
231+ @prefix api: <http://terminusdb.com/schema/api#> .
232+ @prefix owl: <http://www.w3.org/2002/07/owl#> .
233+ @prefix doc: <data/> .
234+
235+ <schema#Philosopher>
236+ a sys:Class ;
237+ <schema#name> xsd:string .
238+
239+ <terminusdb://context>
240+ a sys:Context ;
241+ sys:base "terminusdb:///data/"^^xsd:string ;
242+ sys:schema "terminusdb:///schema#"^^xsd:string .
243+ """
244+ client = Client (docker_url , user_agent = test_user_agent , team = "admin" )
245+ client .connect ()
246+ db_name = "testDB" + str (random ())
247+ client .create_database (db_name , team = "admin" )
248+ client .connect (db = db_name )
249+ client .insert_triples (graph_type = 'schema' , content = ttl , commit_msg = "Insert triples" )
250+ client .insert_document ({"name" : "Socrates" })
251+ assert len (list (client .get_all_documents ())) == 1
252+
253+
169254def test_get_database (docker_url ):
170255 client = Client (docker_url , user_agent = test_user_agent , team = "admin" )
171256 client .connect ()
0 commit comments