Ejemplo n.º 1
0
 def testForSequenceWithOneElement(self):
   """Tests that filter is applied correctly for a one element sequence."""
   query = AddFilterToQueryTest.TestModel.all()
   melange_db.addFilterToQuery(
       query, AddFilterToQueryTest.TestModel.foo, [2])
   self.assertSetEqual(
       set(entity.key() for entity in query.fetch(10)),
       set([self.key2, self.key3]))
Ejemplo n.º 2
0
def queryTasksForMentor(profile_key, extra_filters=None):
  """Returns a query to fetch tasks for which the specified mentor has been
  assigned based on the specified criteria.

  Args:
    profile: profile key of the mentor.
    extra_filters: a dictionary containing additional constraints on the query.
  """
  query = task_model.GCITask.all()
  query.filter('mentors', profile_key)

  extra_filters = extra_filters or {}
  for prop, value in extra_filters.iteritems():
    melange_db.addFilterToQuery(query, prop, value)

  return query
Ejemplo n.º 3
0
def queryTasksForMentor(profile_key, extra_filters=None):
    """Returns a query to fetch tasks for which the specified mentor has been
  assigned based on the specified criteria.

  Args:
    profile: profile key of the mentor.
    extra_filters: a dictionary containing additional constraints on the query.
  """
    query = task_model.GCITask.all()
    query.filter('mentors', profile_key)

    extra_filters = extra_filters or {}
    for prop, value in extra_filters.iteritems():
        melange_db.addFilterToQuery(query, prop, value)

    return query
Ejemplo n.º 4
0
  def testForSequentialValues(self):
    """Tests that filter is applied correctly for sequential values."""
    # test for a list
    query = AddFilterToQueryTest.TestModel.all()
    melange_db.addFilterToQuery(
        query, AddFilterToQueryTest.TestModel.foo, [1, 2])
    self.assertSetEqual(
        set(entity.key() for entity in query.fetch(10)),
        set([self.key1, self.key2, self.key3]))

    # test for a tuple
    query = AddFilterToQueryTest.TestModel.all()
    melange_db.addFilterToQuery(
        query, AddFilterToQueryTest.TestModel.foo, (1, 2))
    self.assertSetEqual(
        set(entity.key() for entity in query.fetch(10)),
        set([self.key1, self.key2, self.key3]))