示例#1
0
 def test_accept_complicated_filter(self):
     filter_request = [
         ["id", "=", 1],
         "and",
         ["!", ["comment", "=", "2664Л-1"]],
         "and",
         [
             [
                 ["date", ">=", "2015/09/29"],
                 "and",
                 ["date", "<", "2015/09/30"]
             ],
             "or",
             [
                 ["date", ">=", "2017/01/01"],
                 "and",
                 ["date", "<", "2018/01/01"]
             ]
         ]
     ]
     q = Q(**{'id': 1}) & \
         ~Q(**{'comment': '2664Л-1'}) & \
         (
             (
                     Q(**{'date__gte': '2015-09-29'}) &
                     Q(**{'date__lt': '2015-09-30'})
             ) |
             (
                     Q(**{'date__gte': '2017-01-01'}) &
                     Q(**{'date__lt': '2018-01-01'})
             )
         )
     self.assertEqual(q,  build_q_object(filter_request, ContributionsInformation))
示例#2
0
 def test_not_blank_date(self):
     filter_request = ["date", "<>", '']
     self.assertEqual(None,  build_q_object(filter_request, ContributionsInformation))
示例#3
0
 def test_accept_ne(self):
     filter_request = ["id", "<>", 1]
     self.assertEqual(Q(**{'id__ne': 1}),  build_q_object(filter_request, Organization))
示例#4
0
 def test_not_null_date(self):
     filter_request = ["date", "<>", None]
     self.assertEqual(Q(**{'date__isnull': False}),  build_q_object(filter_request, ContributionsInformation))
示例#5
0
 def test_accept_contains(self):
     filter_request = ["id", "=", 1]
     self.assertEqual(Q(**{'id': 1}), build_q_object(filter_request, Organization))