예제 #1
0
파일: test_dgeq.py 프로젝트: qcoumes/dgeq
 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))
예제 #2
0
파일: test_dgeq.py 프로젝트: qcoumes/dgeq
 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))
예제 #3
0
파일: test_dgeq.py 프로젝트: qcoumes/dgeq
    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))