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
def test_add_triples_statements(conn, ex): s = Statement(ex.s, ex.p, ex.o) conn.addTriples([s]) assert conn.getStatements().asList() == [s]
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
def test_statement_from_strings_object(ex): stmt = Statement('<ex://s>', '<ex://p>', '<ex://o>') assert stmt.getObject() == ex.o
def test_statement_from_strings_predicate(ex): stmt = Statement('<ex://s>', '<ex://p>', '<ex://o>') assert stmt.getPredicate() == ex.p
def test_stmt_str(ex): # This used to raise an error, see bug25079 assert 'ex' in str(Statement(ex.s, ex.p, ex.o))
def test_quad_len(s, p, o, g): assert len(Statement(s, p, o, g)) == 4
def test_triple_len(s, p, o): assert len(Statement(s, p, o)) == 3