Beispiel #1
0
    def test_renderer(self):
        filename = os.path.dirname(__file__) + '/sample_files/rend-file.xml'

        comparation_filename = os.path.dirname(__file__) + \
                               '/sample_files/expected-rend-file.xml'

        from_node = Node('node_zero')
        node = Node('node_one')

        anchors = ('1', '2')
        region = Region('region_one', *anchors)

        node.add_region(region)

        features = {'name': 'feature_name',
                    'value': 'feature_value'}

        annotation = Annotation('Annotation_label', features, 'annotation-1')

        node.annotations.add(annotation)

        edge = Edge('edge1', from_node, node)

        self.graph.edges.add(edge)
        self.graph.nodes.add(node)
        self.graph.regions.add(region)

        graf_render = GrafRenderer(filename)
        graf_render.render(self.graph)

        expected_tree = ElementTree.parse(comparation_filename)
        result_tree = ElementTree.parse(filename)

        expected_result = [ElementTree.tostring(i) for i in
                           expected_tree.getroot()]
        result = [ElementTree.tostring(i) for i in
                  result_tree.getroot()]

        assert (result[0] == expected_result[0])
        assert (result[1] == expected_result[1])
        assert (result[2] == expected_result[2])
        assert (result[3] == expected_result[3])
Beispiel #2
0
    def test_renderer(self):
        filename = os.path.dirname(__file__) + '/sample_files/rend-file.xml'

        comparation_filename = os.path.dirname(__file__) + \
                               '/sample_files/expected-rend-file.xml'

        from_node = Node('node_zero')
        node = Node('node_one')

        anchors = ('1', '2')
        region = Region('region_one', *anchors)

        node.add_region(region)

        features = {'name': 'feature_name', 'value': 'feature_value'}

        annotation = Annotation('Annotation_label', features, 'annotation-1')

        node.annotations.add(annotation)

        edge = Edge('edge1', from_node, node)

        self.graph.edges.add(edge)
        self.graph.nodes.add(node)
        self.graph.regions.add(region)

        graf_render = GrafRenderer(filename)
        graf_render.render(self.graph)

        expected_tree = ElementTree.parse(comparation_filename)
        result_tree = ElementTree.parse(filename)

        expected_result = [
            ElementTree.tostring(i) for i in expected_tree.getroot()
        ]
        result = [ElementTree.tostring(i) for i in result_tree.getroot()]

        assert (result[0] == expected_result[0])
        assert (result[1] == expected_result[1])
        assert (result[2] == expected_result[2])
        assert (result[3] == expected_result[3])