Ejemplo n.º 1
0
 def test_patterns_arg_adds_clauses(self):
     select = Select([], [(v.x, FOAF.name, v.name)])
     for pattern in select._where.patterns:
         if isinstance(pattern, (Triple, GraphPattern)):
             break
     else:
         assert False
Ejemplo n.º 2
0
    def __init__(self,
                 class_,
                 type_or_select,
                 identifier=None,
                 properties=None):
        self.class_ = class_

        if identifier is None:
            identifier = Variable(class_.__name__)
        self.identifier = identifier

        if isinstance(type_or_select, Select):
            select = type_or_select
        else:
            rdf_type = type_or_select
            select = Select([identifier], [(identifier, is_a, rdf_type)])

        if identifier not in select.projection:
            raise InvalidRequestError("Select must include identifier.")

        self.select = select
        self.setup_class(properties or {})
Ejemplo n.º 3
0
 def setup(self):
     self.select = Select([])
Ejemplo n.º 4
0
 def setup(self):
     self.select = Select(['*'])
Ejemplo n.º 5
0
 def test_variables_arg_adds_variables(self):
     select = Select([Variable('foo')])
     assert Variable('foo') in select.projection
Ejemplo n.º 6
0
 def test_variables_arg_is_sufficient(self):
     try:
         select = Select([v.x])
     except Exception:
         assert False