From 1287aff447516eb7d087c1034556b40386ca4b6f Mon Sep 17 00:00:00 2001
From: fspreck <f.spreckelsen@indiscale.com>
Date: Fri, 13 Oct 2023 09:16:06 +0200
Subject: [PATCH] TST: Add unit tests for errors in case of references

---
 unittests/test_json_schema_exporter.py | 47 ++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/unittests/test_json_schema_exporter.py b/unittests/test_json_schema_exporter.py
index 3a0729dd..ee81fed0 100644
--- a/unittests/test_json_schema_exporter.py
+++ b/unittests/test_json_schema_exporter.py
@@ -22,6 +22,8 @@
 
 import linkahead as db
 
+from pytest import raises
+
 from caosadvancedtools.json_schema_exporter import recordtype_to_json_schema as rtjs
 
 
@@ -51,3 +53,48 @@ def test_empty_rt():
     assert "description" in schema["properties"]
     assert schema["properties"]["name"]["type"] == "string"
     assert schema["properties"]["description"]["type"] == "string"
+
+
+def test_rt_with_scalar_props():
+
+    pass
+
+
+def test_rt_with_list_props():
+
+    pass
+
+
+def test_rt_with_references():
+    """References and lists of references will come later, so test if the errors
+    are thrown correctly.
+
+    """
+
+    rt = db.RecordType()
+    rt.add_property(name="RefProp", datatype=db.REFERENCE)
+
+    with raises(NotImplementedError):
+
+        rtjs(rt)
+
+    rt = db.RecordType()
+    rt.add_property(name="RefProp", datatype="OtherType")
+
+    with raises(NotImplementedError):
+
+        rtjs(rt)
+
+    rt = db.RecordType()
+    rt.add_property(name="RefProp", datatype=db.LIST(db.REFERENCE))
+
+    with raises(NotImplementedError):
+
+        rtjs(rt)
+
+    rt = db.RecordType()
+    rt.add_property(name="RefProp", datatype=db.LIST("OtherType"))
+
+    with raises(NotImplementedError):
+
+        rtjs(rt)
-- 
GitLab