Exemple #1
0
 def compare_node(self, lhs: Node, rhs: Node):
     if lhs.get_id() != rhs.get_id():
         return False
     if not self._strict:
         return True
     if len(lhs.tags()) != len(rhs.tags()):
         return False
     for tag in lhs.tags():
         if not rhs.has_tag(tag):
             return False
         lprops = lhs.propertys(tag)
         rprops = rhs.propertys(tag)
         if not self.compare_map(lprops, rprops):
             return False
     return True
Exemple #2
0
    def test_node_api(self):
        test_set = set()
        test_set.add(Value())
        node = Node(self.get_vertex_value(b'Tom'))
        assert 'Tom' == node.get_id().as_string()

        assert node.has_tag('tag2')

        assert ['prop0', 'prop1', 'prop2', 'prop3',
                'prop4'] == node.prop_names('tag2')

        assert [0, 1, 2, 3,
                4] == [(value.as_int()) for value in node.prop_values('tag2')]

        assert ['tag0', 'tag1', 'tag2'] == node.tags()

        expect_propertys = {}
        for key in node.properties('tag2').keys():
            expect_propertys[key] = node.properties('tag2')[key].as_int()
        assert {
            'prop0': 0,
            'prop1': 1,
            'prop2': 2,
            'prop3': 3,
            'prop4': 4
        } == expect_propertys
Exemple #3
0
    def test_node_api(self):
        node = Node(self.get_vertex_value('Tom'))
        assert 'Tom' == node.get_id()

        assert node.has_tag('tag2')

        print(node.prop_names('tag2'))
        assert ['prop0', 'prop1', 'prop2', 'prop3',
                'prop4'] == node.prop_names('tag2')

        assert [0, 1, 2, 3, 4] == node.prop_values('tag2')

        assert ['tag0', 'tag1', 'tag2'] == node.tags()

        assert {
            'prop0': 0,
            'prop1': 1,
            'prop2': 2,
            'prop3': 3,
            'prop4': 4
        } == node.propertys('tag2')

        expect_str = "{Node}([Tom]:{" \
                     "{tag_name: tag0, props: {'prop0': 0, 'prop1': 1, 'prop2': 2, 'prop3': 3, 'prop4': 4}}," \
                     "{tag_name: tag1, props: {'prop0': 0, 'prop1': 1, 'prop2': 2, 'prop3': 3, 'prop4': 4}}," \
                     "{tag_name: tag2, props: {'prop0': 0, 'prop1': 1, 'prop2': 2, 'prop3': 3, 'prop4': 4}}})"
        assert str(node) == expect_str