Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test for #286 #290

Merged
merged 1 commit into from
May 23, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions test/test_iomemory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@

from rdflib import Graph, Literal, Namespace

def test_concurrent1():
dns = Namespace(u"http://www.example.com/")

store = plugin.get("IOMemory", Store)()
g1 = Graph(store=store)

g1.add((dns.Name, dns.prop, Literal(u"test")))
g1.add((dns.Name, dns.prop, Literal(u"test2")))
g1.add((dns.Name, dns.prop, Literal(u"test3")))

n = len(g1)
i = 0

for t in g1.triples((None, None, None)):
i+=1
# next line causes problems because it adds a new Subject that needs
# to be indexed in __subjectIndex dictionary in IOMemory Store.
# which invalidates the iterator used to iterate over g1
g1.add(t)

assert i == n

def test_concurrent2():
dns = Namespace(u"http://www.example.com/")

Expand All @@ -23,12 +45,21 @@ def test_concurrent2():
g1.add((dns.Name, dns.prop, Literal(u"test2")))
g1.add((dns.Name, dns.prop, Literal(u"test3")))

for t in g1.triples((None, dns.prop, None)):
n = len(g1)
i = 0

for t in g1.triples((None, None, None)):
i+=1
g2.add(t)
# next line causes problems because it adds a new Subject that needs
# to be indexed in __subjectIndex dictionary in IOMemory Store.
# which invalidates the iterator used to iterate over g1
g2.add((dns.Name1, dns.prop1, Literal(u"test")))
g2.add((dns.Name1, dns.prop, Literal(u"test")))
g2.add((dns.Name, dns.prop, Literal(u"test4")))


assert i == n

if __name__ == '__main__':
test_concurrent1()
test_concurrent2()