diff --git a/goblin/abc.py b/goblin/abc.py index a6a20dede885590e8993dad84b9a930a2eb41c92..cc24c9cce80a527abeb2f289f0f55dd4c1aa5039 100644 --- a/goblin/abc.py +++ b/goblin/abc.py @@ -57,6 +57,7 @@ class DataType(abc.ABC): return val def validate_vertex_prop(self, val, card, vertex_prop, data_type): + from .element import VertexProperty if card == Cardinality.list_: if isinstance(val, list): val = val @@ -80,8 +81,11 @@ class DataType(abc.ABC): val = set([val]) vertex_props = set([]) for v in val: - vp = vertex_prop(data_type, card=card) - vp.value = self.validate(v) + if not isinstance(v, VertexProperty): + vp = vertex_prop(data_type, card=card) + vp.value = self.validate(v) + else: + vp = v vertex_props.add(vp) val = manager.SetVertexPropertyManager( data_type, vertex_prop, card, vertex_props) diff --git a/tests/test_properties.py b/tests/test_properties.py index 10d546adbf0d8782dadf27c18f89a9619210e569..bb7a6204cbd305c7eb3f81b023ef4d4555212e1f 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -141,7 +141,10 @@ def test_set_change_set_card_vertex_property(place): with pytest.raises(exception.ValidationError): place.important_numbers.add('dude') - +def test_set_card_union(place): + place.important_numbers = set([1, 2, 3]) + place.important_numbers = place.important_numbers.union({3, 4, 5}) + def test_set_card_validation_vertex_property(place): with pytest.raises(exception.ValidationError): place.important_numbers = set(['hello', 2, 3])