@@ -117,6 +117,7 @@ def test_create_schema_model_valid_data(
117
117
)
118
118
assert schema_instance .entities ["AGE" ]["description" ] == "Age of a person in years."
119
119
120
+ assert schema_instance .relations
120
121
assert (
121
122
schema_instance .relations ["EMPLOYED_BY" ]["description" ]
122
123
== "Indicates employment relationship."
@@ -134,6 +135,7 @@ def test_create_schema_model_valid_data(
134
135
{"description" : "" , "name" : "end_time" , "type" : "LOCAL_DATETIME" },
135
136
]
136
137
138
+ assert schema_instance .potential_schema
137
139
assert schema_instance .potential_schema == potential_schema
138
140
139
141
@@ -159,6 +161,7 @@ def test_create_schema_model_missing_description(
159
161
160
162
assert schema_instance .entities ["ORGANIZATION" ]["description" ] == ""
161
163
assert schema_instance .entities ["AGE" ]["description" ] == ""
164
+ assert schema_instance .relations
162
165
assert schema_instance .relations ["ORGANIZED_BY" ]["description" ] == ""
163
166
assert schema_instance .relations ["ATTENDED_BY" ]["description" ] == ""
164
167
@@ -242,6 +245,7 @@ async def test_run_method(
242
245
)
243
246
assert schema .entities ["AGE" ]["description" ] == "Age of a person in years."
244
247
248
+ assert schema .relations
245
249
assert (
246
250
schema .relations ["EMPLOYED_BY" ]["description" ]
247
251
== "Indicates employment relationship."
@@ -255,6 +259,7 @@ async def test_run_method(
255
259
== "Indicates attendance at an event."
256
260
)
257
261
262
+ assert schema .potential_schema
258
263
assert schema .potential_schema == potential_schema
259
264
260
265
@@ -327,6 +332,7 @@ def test_create_schema_model_missing_properties(
327
332
schema_instance .entities ["AGE" ]["properties" ] == []
328
333
), "Expected empty properties for AGE"
329
334
335
+ assert schema_instance .relations
330
336
assert (
331
337
schema_instance .relations ["EMPLOYED_BY" ]["properties" ] == []
332
338
), "Expected empty properties for EMPLOYED_BY"
@@ -336,3 +342,80 @@ def test_create_schema_model_missing_properties(
336
342
assert (
337
343
schema_instance .relations ["ATTENDED_BY" ]["properties" ] == []
338
344
), "Expected empty properties for ATTENDED_BY"
345
+
346
+
347
+ def test_create_schema_model_no_potential_schema (
348
+ schema_builder : SchemaBuilder ,
349
+ valid_entities : list [SchemaEntity ],
350
+ valid_relations : list [SchemaRelation ],
351
+ ) -> None :
352
+ schema_instance = schema_builder .create_schema_model (
353
+ valid_entities , valid_relations
354
+ )
355
+
356
+ assert (
357
+ schema_instance .entities ["PERSON" ]["description" ]
358
+ == "An individual human being."
359
+ )
360
+ assert schema_instance .entities ["PERSON" ]["properties" ] == [
361
+ {"description" : "" , "name" : "birth date" , "type" : "ZONED_DATETIME" },
362
+ {"description" : "" , "name" : "name" , "type" : "STRING" },
363
+ ]
364
+ assert (
365
+ schema_instance .entities ["ORGANIZATION" ]["description" ]
366
+ == "A structured group of people with a common purpose."
367
+ )
368
+ assert schema_instance .entities ["AGE" ]["description" ] == "Age of a person in years."
369
+
370
+ assert schema_instance .relations
371
+ assert (
372
+ schema_instance .relations ["EMPLOYED_BY" ]["description" ]
373
+ == "Indicates employment relationship."
374
+ )
375
+ assert (
376
+ schema_instance .relations ["ORGANIZED_BY" ]["description" ]
377
+ == "Indicates organization responsible for an event."
378
+ )
379
+ assert (
380
+ schema_instance .relations ["ATTENDED_BY" ]["description" ]
381
+ == "Indicates attendance at an event."
382
+ )
383
+ assert schema_instance .relations ["EMPLOYED_BY" ]["properties" ] == [
384
+ {"description" : "" , "name" : "start_time" , "type" : "LOCAL_DATETIME" },
385
+ {"description" : "" , "name" : "end_time" , "type" : "LOCAL_DATETIME" },
386
+ ]
387
+
388
+
389
+ def test_create_schema_model_no_relations_or_potential_schema (
390
+ schema_builder : SchemaBuilder ,
391
+ valid_entities : list [SchemaEntity ],
392
+ ) -> None :
393
+ schema_instance = schema_builder .create_schema_model (valid_entities )
394
+
395
+ assert (
396
+ schema_instance .entities ["PERSON" ]["description" ]
397
+ == "An individual human being."
398
+ )
399
+ assert schema_instance .entities ["PERSON" ]["properties" ] == [
400
+ {"description" : "" , "name" : "birth date" , "type" : "ZONED_DATETIME" },
401
+ {"description" : "" , "name" : "name" , "type" : "STRING" },
402
+ ]
403
+ assert (
404
+ schema_instance .entities ["ORGANIZATION" ]["description" ]
405
+ == "A structured group of people with a common purpose."
406
+ )
407
+ assert schema_instance .entities ["AGE" ]["description" ] == "Age of a person in years."
408
+
409
+
410
+ def test_create_schema_model_missing_relations (
411
+ schema_builder : SchemaBuilder ,
412
+ valid_entities : list [SchemaEntity ],
413
+ potential_schema : list [tuple [str , str , str ]],
414
+ ) -> None :
415
+ with pytest .raises (SchemaValidationError ) as exc_info :
416
+ schema_builder .create_schema_model (
417
+ entities = valid_entities , potential_schema = potential_schema
418
+ )
419
+ assert "Relations must also be provided when using a potential schema." in str (
420
+ exc_info .value
421
+ ), "Should fail due to missing relations"
0 commit comments