class TestResultValueQuery(unittest.TestCase): def setUp(self): def values_source(): return ["1st_obj", "2nd_obj"], ["1st_uriref", "2nd_uriref"] self.store = MockStore() self.value = ResourceValue(values_source, MockResource(self.store), "some_name") def test_limit_offset(self): """ Test limit, offset. """ self.store.expect_args({"limit" : 10, "offset" : 5}) list(self.value.limit(10).offset(5)) def test_full(self): """ Test full(). """ self.store.expect_args({"full" : True, "only_direct" : True}) list(self.value.full(only_direct = True)) def test_order_desc(self): """ Test order, desc. """ self.store.expect_args({"order" : "some_attr", "desc" : True}) list(self.value.order("some_attr").desc()) def test_get_by(self): """ Test get_by. """ expected = [(surf.ns.FOAF["name"], "Jane", True)] self.store.expect_args({"get_by" : expected}) list(self.value.get_by(foaf_name = "Jane")) def test_context(self): """ Test context. """ self.store.expect_args({"context" : "my_context"}) list(self.value.context("my_context")) def test_filter(self): """ Test filter. """ self.store.expect_args({"filter" : [(surf.ns.FOAF["name"], "f", True)]}) list(self.value.filter(foaf_name = "f")) def test_get_by_resource(self): """ Test that get_by accepts Resources as values. """ resource = MockResource() expected = [(surf.ns.FOAF["knows"], resource.subject, True)] self.store.expect_args({"get_by" : expected}) list(self.value.get_by(foaf_knows = resource))