예제 #1
0
파일: tests.py 프로젝트: cdrx/django-extjs
 def test_query_filter(self):
     """Test simples args
     """
     self.request = HttpRequest()
     qr = Author.objects.all()
     qrd = QueryDict('start=0&dir=ASC&name=tata')
     self.request.REQUEST = qrd
     fields = {"name": "name", "desc": "description", "id": "id"}
     result_qr = query_from_request(self.request, qr, fields=fields)
     self.assertEqual(list(result_qr), [self.auth1])
예제 #2
0
파일: tests.py 프로젝트: cdrx/django-extjs
 def test_query_filter(self):
     """Test simples args
     """
     self.request = HttpRequest()
     qr = Author.objects.all()
     qrd = QueryDict('start=0&dir=ASC&name=tata')
     self.request.REQUEST = qrd
     fields = {"name": "name", "desc": "description", "id": "id"}
     result_qr = query_from_request(self.request, qr, fields=fields)
     self.assertEqual(list(result_qr), [self.auth1])
예제 #3
0
파일: tests.py 프로젝트: cdrx/django-extjs
 def test_query_order_reverse(self):
     """Test order DESC
     """
     self.request = HttpRequest()
     qr = Author.objects.all()
     qrd = QueryDict('sort=dame&dir=DESC')
     self.request.REQUEST = qrd
     fields = {"dame": "name", "desc": "description", "pk": "id"}
     result_qr = query_from_request(self.request, qr, fields=fields)
     self.assertEqual(result_qr.count(), 5)
     self.assertEqual(result_qr[4], self.auth4)
예제 #4
0
파일: tests.py 프로젝트: cdrx/django-extjs
 def test_query_order_reverse(self):
     """Test order DESC
     """
     self.request = HttpRequest()
     qr = Author.objects.all()
     qrd = QueryDict('sort=dame&dir=DESC')
     self.request.REQUEST = qrd
     fields = {"dame": "name", "desc": "description", "pk": "id"}
     result_qr = query_from_request(self.request, qr, fields=fields)
     self.assertEqual(result_qr.count(), 5)
     self.assertEqual(result_qr[4], self.auth4)
예제 #5
0
파일: tests.py 프로젝트: cdrx/django-extjs
    def test_query_limit(self):
        """Test limit args
        """
        # test limit
        self.request = HttpRequest()
        qr = Author.objects.all()
        qrd = QueryDict('sort=id&dir=ASC&limit=2')
        self.request.REQUEST = qrd
        fields = {"name": "name", "desc": "description", "id": "id"}
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertEqual(result_qr.count(), 2)

        # test start only
        qrd = QueryDict('start=2&sort=id&dir=ASC')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertTrue(self.auth1 not in result_qr)
        self.assertEqual(result_qr.count(), 3)

        # test start & limit
        qrd = QueryDict('start=2&sort=id&dir=ASC&limit=2')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertTrue(self.auth1 not in result_qr)
        self.assertEqual(result_qr.count(), 2)

        # test exception
        qrd = QueryDict('start=2&sort=id&dir=ASC&limit=abc')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertEqual(result_qr.count(), 0)

        # test high limit
        qrd = QueryDict('start=4&sort=id&dir=ASC&limit=20')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertEqual(result_qr.count(), 1)

        # test high start
        qrd = QueryDict('start=24&sort=id&dir=ASC&limit=20')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertEqual(result_qr.count(), 0)
예제 #6
0
파일: tests.py 프로젝트: cdrx/django-extjs
    def test_query_limit(self):
        """Test limit args
        """
        # test limit
        self.request = HttpRequest()
        qr = Author.objects.all()
        qrd = QueryDict('sort=id&dir=ASC&limit=2')
        self.request.REQUEST = qrd
        fields = {"name": "name", "desc": "description", "id": "id"}
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertEqual(result_qr.count(), 2)

        # test start only
        qrd = QueryDict('start=2&sort=id&dir=ASC')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertTrue(self.auth1 not in result_qr)
        self.assertEqual(result_qr.count(), 3)

        # test start & limit
        qrd = QueryDict('start=2&sort=id&dir=ASC&limit=2')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertTrue(self.auth1 not in result_qr)
        self.assertEqual(result_qr.count(), 2)

        # test exception
        qrd = QueryDict('start=2&sort=id&dir=ASC&limit=abc')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertEqual(result_qr.count(), 0)

        # test high limit
        qrd = QueryDict('start=4&sort=id&dir=ASC&limit=20')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertEqual(result_qr.count(), 1)

        # test high start
        qrd = QueryDict('start=24&sort=id&dir=ASC&limit=20')
        self.request.REQUEST = qrd
        result_qr = query_from_request(self.request, qr, fields=fields)
        self.assertEqual(result_qr.count(), 0)