Пример #1
0
def test_pub1_type_publication_is_a_path():
    graph_parser.parse('tests/assets/paper.nt')
    assert [
        u'<http://demo.com/publications.rdf#pub1>',
        u'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>',
        u'<http://demo.com/types.rdf#Publication>'
    ] in graph_parser.paths()
Пример #2
0
def test_tries_to_store_templates(monkeypatch):
    counters = mock_method_with_counter(monkeypatch, db, 'replace_all_templates')

    graph_parser.parse('tests/assets/paper.nt')
    graph_parser.persist_index()

    assert 1 == counters['invocations']
    assert 0 < len(counters['args'][0])
Пример #3
0
def parse():
    clean()

    from app.graph_parser import graph_parser
    from app.index_parser import index_parser

    graph_parser.parse('example-rdfs/tall/paper.nt')
    # graph_parser.parse('example-rdfs/venti/linkedmdb-latest-dump.nt')
    graph_parser.persist_index()
    index_parser.generate_sparse_matrix()

    clean()
Пример #4
0
def test_get_tuple_returns_size_three_list():
    graph_parser.parse('tests/assets/paper.nt')
    graph_parser.persist_index()
    t = index_parser.get_tuple('nod1', ['nod1', 'nod2'])
    assert isinstance(t, list)
    assert 3 == len(t)
Пример #5
0
def test_there_are_5_sinks():
    graph_parser.parse('tests/assets/paper.nt')
    assert 5 == len(graph_parser.triplesink.sinks())
Пример #6
0
def test_2008_is_a_sink():
    graph_parser.parse('tests/assets/paper.nt')
    assert rdflib.term.Literal(u'2008') in graph_parser.triplesink.sinks()
Пример #7
0
def test_conference_is_a_sink():
    graph_parser.parse('tests/assets/paper.nt')
    assert rdflib.term.URIRef(u'http://demo.com/types.rdf#Conference') in graph_parser.triplesink.sinks()
Пример #8
0
def test_pub1_and_pub2_are_sources():
    graph_parser.parse('tests/assets/paper.nt')
    sources = graph_parser.triplesink.sources()
    assert 2 == len(sources)
    assert rdflib.term.URIRef(u'http://demo.com/publications.rdf#pub1') in sources
    assert rdflib.term.URIRef(u'http://demo.com/publications.rdf#pub2') in sources
Пример #9
0
def test_there_are_10_nodes():
    graph_parser.parse('tests/assets/paper.nt')
    assert 10 == len(graph_parser.triplesink.nodes())
Пример #10
0
def test_2008_is_a_node():
    graph_parser.parse('tests/assets/paper.nt')
    assert u'"2008"' in graph_parser.triplesink.nodes()
Пример #11
0
def test_aut2_is_a_node():
    graph_parser.parse('tests/assets/paper.nt')
    assert u'<http://demo.com/authors.rdf#aut2>' in graph_parser.triplesink.nodes()
Пример #12
0
def test_there_are_5_templates():
    graph_parser.parse('tests/assets/paper.nt')
    assert 5 == len(graph_parser.templates())
Пример #13
0
def test_hash_acceptedBy_hash_type_is_a_template():
    graph_parser.parse('tests/assets/paper.nt')
    assert [
        u'<http://demo.com/syntax#acceptedBy>',
        u'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>',
    ] in graph_parser.templates()
Пример #14
0
def test_there_are_10_paths():
    graph_parser.parse('tests/assets/paper.nt')
    assert 10 == len(graph_parser.paths())