Exemple #1
0
    def get(self, node_param):
        from app.matrix_searcher import matrix_searcher
        from app.persistance import db

        node_index = db.search_node(node_param)

        result = {
                'query': node_param,
                'selected_node': None,
                'query_result': None
        }

        if node_index != None:
            result['selected_node'] = db.get_node(node_index)
            result['query_result'] = matrix_searcher.node_query(node_index)
        else:
            self.set_status(404)

        self.finish(result)
Exemple #2
0
 def path_query(self, path_index):
     row = db.get_row(path_index)
     nodes = []
     for node_index in row.keys():
         nodes.append(db.get_node(node_index))
     return nodes
Exemple #3
0
def test_stored_nodes_maintains_order():
    nodes = ['nod1', 'nod2', 'nod3']
    db.replace_all_nodes(nodes)
    assert 'nod1' == db.get_node(0)
    assert 'nod2' == db.get_node(1)
    assert 'nod3' == db.get_node(2)
Exemple #4
0
def test_stored_node_returns_as_string():
    nodes = ['nod1', 'nod2', 'nod3']
    db.replace_all_nodes(nodes)
    assert isinstance(db.get_node(1), str)