def test_replace_all_nodes_doesnt_change_templates():
    templates = [['nod1', 'nod2'], ['nod2', 'nod3']]
    db.replace_all_templates(templates)
    nodes = ['nod1', 'nod2', 'nod3']
    db.replace_all_nodes(nodes)
    assert 3 == db.count_nodes()
    assert 2 == db.count_templates()
Exemple #2
0
def test_replace_all_paths_doesnt_change_nodes():
    nodes = ['nod1', 'nod2', 'nod3']
    db.replace_all_nodes(nodes)
    paths = [['nod1', 'edge1', 'nod2'], ['nod2', 'edge2', 'nod3']]
    db.replace_all_paths(paths)
    assert 3 == db.count_nodes()
    assert 2 == db.count_paths()
def test_generate_sparse_matrix_equals_to_paper_example():
    db.replace_all_nodes(paper_nodes)
    db.replace_all_paths(paper_paths)
    db.replace_all_templates(paper_templates)

    index_parser.generate_sparse_matrix()

    assert paper_matrix == db.get_sparse_matrix()
def create_indexes():
    nodes = ['nod1', 'nod2', 'nod3']
    paths = [['nod1', 'edge1', 'nod2'], ['nod2', 'edge2', 'nod3']]
    templates = [['nod1', 'nod2'], ['nod2', 'nod3']]
    db.replace_all_nodes(nodes)
    db.replace_all_paths(paths)
    db.replace_all_templates(templates)

    return nodes, paths, templates
Exemple #5
0
def test_replace_all_nodes_with_two_nodes():
    nodes = ['nod1', 'nod2']
    db.replace_all_nodes(nodes)
    assert 2 == db.count_nodes()
Exemple #6
0
def test_get_node_index_by_exact_name():
    nodes = ['the_first_node', 'a_second_node', 'third_node_returns']
    db.replace_all_nodes(nodes)
    assert 0 == db.search_node(nodes[0])
    assert 1 == db.search_node(nodes[1])
    assert 2 == db.search_node(nodes[2])
Exemple #7
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 #8
0
def test_stored_node_returns_as_string():
    nodes = ['nod1', 'nod2', 'nod3']
    db.replace_all_nodes(nodes)
    assert isinstance(db.get_node(1), str)
Exemple #9
0
def test_replace_all_nodes_with_three_nodes():
    nodes = ['nod1', 'nod2', 'nod3']
    db.replace_all_nodes(nodes)
    assert 3 == db.count_nodes()
Exemple #10
0
 def persist_index(self):
     db.replace_all_nodes(self.triplesink.nodes())
     db.replace_all_paths(self.paths())
     db.replace_all_templates(self.templates())