def test_get_nodes_with_not_exist_name(self, load_graph_record, name,
                                           node_type):
        """Test getting nodes with not exist name."""
        with pytest.raises(ParamValueError) as exc_info:
            graph_processor = GraphProcessor(self._train_id,
                                             self._mock_data_manager)
            graph_processor.get_nodes(name, node_type)

        if name:
            assert "The node name is not in graph." in exc_info.value.message
        else:
            assert f'The node name "{name}" not in graph, node type is {node_type}.' in exc_info.value.message
    def test_get_nodes_success(self, load_graph_record, name, node_type,
                               result_file):
        """Test getting nodes successfully."""

        graph_processor = GraphProcessor(self._train_id,
                                         self._mock_data_manager)
        results = graph_processor.get_nodes(name, node_type)
        self.compare_result_with_file(results, result_file)
Example #3
0
def graph_nodes():
    """
    Interface to get graph nodes.

    Returns:
        Response, which contains a JSON object.

    """
    name = request.args.get('name', default=None)
    node_type = request.args.get('type', default='name_scope')
    tag = request.args.get("tag", default=None)
    train_id = get_train_id(request)

    graph_process = GraphProcessor(train_id, DATA_MANAGER, tag)
    response = graph_process.get_nodes(name=name, node_type=node_type)
    return jsonify(response)