def test_open_open_close_query(tempdir): bds1 = BundleDependencyStore() bds2 = BundleDependencyStore() store_cache = StoreCache() store = plugin_get('FileStorageZODB', Store)() store.open(p(tempdir, 'db.fs')) trip = (URIRef('http://example.org/a'), URIRef('http://example.org/b'), URIRef('http://example.org/c')) store.add(trip, context=None) store.close() conf = dict(type='FileStorageZODB', conf={ 'read_only': True, 'url': p(tempdir, 'db.fs') }, cache=store_cache) print("OPEN BDS 1") bds1.open(conf) print("OPEN BDS 2") bds2.open(conf) print("CLOSE BDS 1") bds1.close() assert list(bds2.triples((None, None, None)))[0][0] == trip
def test_includes_triples(): iom = IOMemory() iom.add((URIRef('http://example.org/a'), URIRef('http://example.org/b'), URIRef('http://example.org/c')), context='http://example.org/ctx') bds = BundleDependencyStore(iom) assert 1 == sum(1 for _ in bds.triples((None, None, None)))
def test_excludes_all_for_excluded_context(): iom = IOMemory() iom.add((URIRef('http://example.org/a'), URIRef('http://example.org/b'), URIRef('http://example.org/c')), context='http://example.org/ctx') iom.add((URIRef('http://example.org/a'), URIRef('http://example.org/b'), URIRef('http://example.org/c')), context='http://example.org/ctx1') bds = BundleDependencyStore(iom, excludes=set(['http://example.org/ctx'])) assert 0 == sum(1 for _ in bds.triples((None, None, None), context='http://example.org/ctx'))
def test_triples_contexts(): iom = IOMemory() ctx = 'http://example.org/ctx' ctx1 = 'http://example.org/ctx1' iom.add((URIRef('http://example.org/a'), URIRef('http://example.org/b'), URIRef('http://example.org/c')), context=ctx) iom.add((URIRef('http://example.org/a'), URIRef('http://example.org/b'), URIRef('http://example.org/c')), context=ctx1) bds = BundleDependencyStore(iom) for t, ctxs in bds.triples((None, None, None)): assert set([ctx, ctx1]) == set(ctxs)