def test__evaluate_no_related(self): dgeq = GenericQuery(Country, QueryDict()) dgeq.fields = {"name", "population", "rivers", "region"} dgeq.arbitrary_fields = set() dgeq.queryset = Country.objects.all() dgeq.related = False rows = dgeq._evaluate() self.assertEqual(DGEQ_DEFAULT_LIMIT, len(rows))
def test__evaluate_each_field_type(self): dgeq = GenericQuery(Country, QueryDict()) dgeq.fields = { "name", "population", "rivers", "region", "rivers_length_avg" } dgeq.arbitrary_fields = {"rivers_length_avg"} dgeq.queryset = Country.objects.all().annotate( rivers_length_avg=models.Avg("rivers__length")) rows = dgeq._evaluate() self.assertEqual(constants.DGEQ_DEFAULT_LIMIT, len(rows))
def test__evaluate_joins(self): dgeq = GenericQuery(Country, QueryDict()) dgeq.fields = {"name", "population", "rivers", "region"} dgeq.arbitrary_fields = set() dgeq.queryset = Country.objects.all() j_rivers = JoinQuery.from_query_value("field=rivers", Country, False, self.censor) j_region = JoinQuery.from_query_value("field=region", Country, False, self.censor) dgeq.add_join("rivers", j_rivers, Country, self.censor) dgeq.add_join("region", j_region, Country, self.censor) rows = dgeq._evaluate() self.assertEqual(DGEQ_DEFAULT_LIMIT, len(rows))