Exemplo n.º 1
0
def node_conditions(node: NodeDesc) -> List[Condition]:
    conditions = [IsNode()]

    for label in node.labels:
        condition = HasLabel(label)
        if condition not in conditions:
            conditions.append(condition)

    for key, value in node.properties.items():
        condition = HasProperty(key, value)
        if condition not in conditions:
            conditions.append(condition)

    return conditions
Exemplo n.º 2
0
def relation_conditions(relation: RelationDesc) -> List[Condition]:
    conditions = [IsRelation()]
    if relation.direction == Direction.OUTGOING:
        conditions.append(IsOutgoing())
    elif relation.direction == Direction.OUTGOING:
        conditions.append(IsIncoming())

    for type in relation.types:
        condition = HasType(type)
        if condition not in conditions:
            conditions.append(condition)

    for key, value in relation.properties.items():
        condition = HasProperty(key, value)
        if condition not in conditions:
            conditions.append(condition)

    return conditions
Exemplo n.º 3
0
 def test__when__validating_has_property__given__payload_with_last_relation_without_key__then_false(
         self):
     condition = HasProperty('last name', 'Coyote')
     assert_that(condition.is_valid(self._payload(Relation))).is_false()
Exemplo n.º 4
0
 def test__when__validating_has_property__given__payload_with_last_relation_with_key_without_value__then_false(
         self):
     condition = HasProperty('current', 123)
     assert_that(condition.is_valid(self._payload(Relation))).is_false()
Exemplo n.º 5
0
 def test__when__validating_has_property__given__payload_with_last_node_with_key_without_value__then_false(
         self):
     condition = HasProperty('name', 'Wrong-Name')
     assert_that(condition.is_valid(self._payload(Node))).is_false()
Exemplo n.º 6
0
 def test__when__validating_has_property__given__empty_payload__then__false(
         self):
     condition = HasProperty('key', 'value')
     assert_that(condition.is_valid([])).is_false()