示例#1
0
def test_remove_statement(conn, s, p, o, x, g):
    conn.add(s, p, o, [g])
    conn.add(x, p, o, [g])
    conn.add(s, x, o, [g])
    conn.add(s, p, x, [g])
    conn.add(s, p, o, [x])
    stmt = Statement(s, p, o, g)
    conn.removeStatement(stmt, [g])
    remaining = conn.getStatements(None, None, None).asList()
    assert len(remaining) == 4
    for r in remaining:
        assert r.getSubject() != s or r.getPredicate() != p \
               or r.getObject() != o or r.getContext() != g
示例#2
0
def test_add_triples_statements(conn, ex):
    s = Statement(ex.s, ex.p, ex.o)
    conn.addTriples([s])
    assert conn.getStatements().asList() == [s]
示例#3
0
def test_triple_ne_quad(ex):
    s1 = Statement(ex.s, ex.p, ex.o)
    s2 = Statement(ex.s, ex.p, ex.o, ex.g)
    assert s1 != s2
示例#4
0
def test_statement_from_strings_object(ex):
    stmt = Statement('<ex://s>', '<ex://p>', '<ex://o>')
    assert stmt.getObject() == ex.o
示例#5
0
def test_statement_from_strings_predicate(ex):
    stmt = Statement('<ex://s>', '<ex://p>', '<ex://o>')
    assert stmt.getPredicate() == ex.p
示例#6
0
def test_stmt_str(ex):
    # This used to raise an error, see bug25079
    assert 'ex' in str(Statement(ex.s, ex.p, ex.o))
示例#7
0
def test_quad_len(s, p, o, g):
    assert len(Statement(s, p, o, g)) == 4
示例#8
0
def test_triple_len(s, p, o):
    assert len(Statement(s, p, o)) == 3