1 from rdflib import Literal
2 from oort.rdfview import QueryContext
3
4
5 from oort.test.test_rdfview import T, testgraph, itemX, Item
6 from oort.test import test_rdfview
7
8
11
12
13 -class TestQueryContext(object):
14
15 - def test_by_attr(self):
19
20 - def test_find_all(self):
24
25 - def test_by_find(self):
30
32 context = QueryContext(testgraph, 'en', queries=[Item])
33 found = context.Item.find_by(name=Literal(u'Item X'))
34 assert list(found)[0].uri == itemX
35
37 def getlang():
38 return 'en'
39 context = QueryContext(testgraph, getlang, queries=[Item])
40 item = context.Item(itemX)
41 self.assert_item_stuff(item)
42
43 - def assert_item_stuff(self, item):
44 assert item.uri == itemX, \
45 "Unexpected uri: %r" % item.uri
46 assert item.title == Literal(u'Example Item', 'en'), \
47 "Unexpected title: %r" % item.title
48