From a6a3f21445120ba634636829dd151ae53ba91b10 Mon Sep 17 00:00:00 2001 From: davebshow <davebshow@gmail.com> Date: Thu, 14 Sep 2017 15:52:42 -0700 Subject: [PATCH] added missing return for VP default property --- goblin/element.py | 5 +++-- tests/conftest.py | 1 + tests/test_properties.py | 2 ++ tests/test_vertex_properties_functional.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/goblin/element.py b/goblin/element.py index 8008b47..3bc10a8 100644 --- a/goblin/element.py +++ b/goblin/element.py @@ -153,7 +153,8 @@ class VertexPropertyDescriptor: if obj is None: return getattr(objtype.__mapping__, self._prop_name) default = self._default - if default: + if default is not None : + default = self._data_type.validate_vertex_prop( default, self._cardinality, self._vertex_property, self._data_type) @@ -185,7 +186,7 @@ class VertexProperty(Vertex, abc.BaseProperty): @property def default(self): - self._default + return self._default @property def data_type(self): diff --git a/tests/conftest.py b/tests/conftest.py index 9dee508..de7cfff 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -56,6 +56,7 @@ class Place(element.Vertex): historical_name = HistoricalName(properties.String, card=Cardinality.list_) important_numbers = element.VertexProperty( properties.Integer, card=Cardinality.set_) + incorporated = element.VertexProperty(properties.Boolean, default=False) class Inherited(Person): diff --git a/tests/test_properties.py b/tests/test_properties.py index e3e5c15..5a1ca13 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -43,6 +43,8 @@ def test_property_default(knows): knows.notes = 'notable' assert knows.notes == 'notable' +def test_false_bool_default(place): + assert place.incorporated.value is False def test_validation(person): person.age = 10 diff --git a/tests/test_vertex_properties_functional.py b/tests/test_vertex_properties_functional.py index d78060c..2193951 100644 --- a/tests/test_vertex_properties_functional.py +++ b/tests/test_vertex_properties_functional.py @@ -97,7 +97,7 @@ async def test_metas(app, place, remote_connection): detroit = await session.save(place) dprops = await g.V(detroit.id).properties().toList() - assert len(dprops) == 3 + assert len(dprops) == 4 trav = g.V(detroit.id).properties('historical_name').valueMap(True) dmetas = await trav.toList() assert dmetas[0]['value'] == 'Detroit' -- GitLab