Skip to content

Commit 025853e

Browse files
committed
add test for embed export
1 parent fd0477f commit 025853e

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/pyirk/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2860,7 +2860,7 @@ def is_subproperty(item: Item, parent_property: Item):
28602860
return is_subproperty(item.R17, parent_property)
28612861

28622862

2863-
def export_entities(path: str, to_file=True, uris=True):
2863+
def export_entities(path: str = None, to_file=True, uris=True):
28642864
d = {}
28652865
entities = [ds.items, ds.relations]
28662866
for entity in entities:
@@ -2896,6 +2896,7 @@ def export_entities(path: str, to_file=True, uris=True):
28962896
d[k] = out
28972897
# todo do we want uris in these statements?
28982898
if to_file:
2899+
assert os.path.isfile(path), "invalid filepath"
28992900
with open(path, "w") as f:
29002901
yaml.dump(d, f)
29012902
return d

tests/test_core.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,3 +2276,12 @@ def test_b04__zebra_puzzle_unlinked_items(self):
22762276
self.assertFalse(rdflib.URIRef(zp.person11.uri) in g.objects())
22772277

22782278
os.unlink(fpath)
2279+
2280+
def test_b05__embedding_export(self):
2281+
res = p.export_entities(to_file=False)
2282+
self.assertIn(
2283+
"'irk:/builtins#I23 equation' 'irk:/builtins#R3 is subclass of' 'irk:/builtins#I21 mathematical relation'",
2284+
res["irk:/builtins#I23"],
2285+
)
2286+
res = p.export_entities(to_file=False, uris=False)
2287+
self.assertIn("'equation' 'is subclass of' 'mathematical relation'", res["irk:/builtins#I23"])

0 commit comments

Comments
 (0)