Skip to content

Commit 6c7553d

Browse files
author
matmoncon
committed
test: update schema test case
1 parent 2a64464 commit 6c7553d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/unit/test_schema.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# pylint: disable=invalid-name, redefined-outer-name, unused-import, missing-module-docstring, missing-class-docstring
22

3+
from pydantic import Field
4+
5+
from pyneo4j_ogm.core.node import NodeModel
6+
from pyneo4j_ogm.fields.property_options import WithOptions
37
from pyneo4j_ogm.pydantic_utils import IS_PYDANTIC_V2, get_schema
48
from tests.fixtures.db_setup import Coffee, Consumed, Developer
59
from tests.utils.string_utils import assert_string_equality
@@ -124,3 +128,25 @@ def test_schema():
124128
schema["definitions"]["Developer"]["properties"]["colleagues"]["properties"]["allow_multiple"]["type"]
125129
== "boolean"
126130
)
131+
132+
133+
def test_schema_with_index_and_constraint():
134+
class TestModel(NodeModel):
135+
uid: WithOptions(str, text_index=True, unique=True) = Field("test-uid") # type: ignore
136+
137+
setattr(TestModel, "_client", None)
138+
139+
schema = get_schema(TestModel)
140+
141+
if IS_PYDANTIC_V2:
142+
assert "text_index" in schema["properties"]["uid"]
143+
assert schema["properties"]["uid"]["text_index"]
144+
145+
assert "uniqueness_constraint" in schema["properties"]["uid"]
146+
assert schema["properties"]["uid"]["uniqueness_constraint"]
147+
else:
148+
assert "text_index" in schema["properties"]["uid"]
149+
assert schema["properties"]["uid"]["text_index"]
150+
151+
assert "uniqueness_constraint" in schema["properties"]["uid"]
152+
assert schema["properties"]["uid"]["uniqueness_constraint"]

0 commit comments

Comments
 (0)