def test_find_template_index(): t1 = ['nod1', 'nod2'] t2 = ['nod2', 'nod3'] templates = [t1, t2] db.replace_all_templates(templates) assert 0 == db.get_template_index(t1) assert 1 == db.get_template_index(t2)
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()
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
def test_replace_all_templates_with_two_templates(): templates = [['nod1', 'nod2'], ['nod2', 'nod3']] db.replace_all_templates(templates) assert 2 == db.count_templates()
def test_not_found_template_index_returns_None(): t1 = ['nod1', 'nod2'] t2 = ['nod2', 'nod3'] templates = [t1, t2] db.replace_all_templates(templates) assert None == db.get_template_index(['nod3', 'nod4'])
def test_stored_templates_maintains_order(): templates = [['nod1', 'nod2'], ['nod2', 'nod3']] db.replace_all_templates(templates) assert ['nod1', 'nod2'] == db.get_template(0) assert ['nod2', 'nod3'] == db.get_template(1)
def test_not_stored_template_returns_None(): templates = [['nod1', 'nod2'], ['nod2', 'nod3']] db.replace_all_templates(templates) assert None == db.get_template(3)
def test_stored_template_returns_as_list(): templates = [['nod1', 'nod2'], ['nod2', 'nod3']] db.replace_all_templates(templates) assert isinstance(db.get_template(1), list)
def persist_index(self): db.replace_all_nodes(self.triplesink.nodes()) db.replace_all_paths(self.paths()) db.replace_all_templates(self.templates())