Example #1
0
 def test_filtering_stop(self):
     qs = mock.Mock(spec=['filter'])
     value = mock.Mock(start=None, stop=datetime(2015, 9, 6, 11, 45))
     f = DateTimeFromToRangeFilter()
     f.filter(qs, value)
     qs.filter.assert_called_once_with(
         None__lte=datetime(2015, 9, 6, 11, 45))
Example #2
0
 def test_filtering_start(self):
     qs = mock.Mock(spec=['filter'])
     value = mock.Mock(start=datetime(2015, 4, 7, 8, 30), stop=None)
     f = DateTimeFromToRangeFilter()
     f.filter(qs, value)
     qs.filter.assert_called_once_with(
         None__gte=datetime(2015, 4, 7, 8, 30))
Example #3
0
 def test_filtering_ignores_lookup_expr(self):
     qs = mock.Mock()
     value = mock.Mock(
         start=datetime(2015, 4, 7, 8, 30), stop=datetime(2015, 9, 6, 11, 45))
     f = DateTimeFromToRangeFilter(lookup_expr='gte')
     f.filter(qs, value)
     qs.filter.assert_called_once_with(
         None__range=(datetime(2015, 4, 7, 8, 30), datetime(2015, 9, 6, 11, 45)))
Example #4
0
 def test_filtering_range(self):
     qs = mock.Mock(spec=['filter'])
     value = mock.Mock(
         start=datetime(2015, 4, 7, 8, 30), stop=datetime(2015, 9, 6, 11, 45))
     f = DateTimeFromToRangeFilter()
     f.filter(qs, value)
     qs.filter.assert_called_once_with(
         None__range=(datetime(2015, 4, 7, 8, 30), datetime(2015, 9, 6, 11, 45)))
Example #5
0
 def test_filtering_ignores_lookup_expr(self):
     qs = mock.Mock()
     value = mock.Mock(
         start=datetime(2015, 4, 7, 8, 30), stop=datetime(2015, 9, 6, 11, 45))
     f = DateTimeFromToRangeFilter(lookup_expr='gte')
     f.filter(qs, value)
     qs.filter.assert_called_once_with(
         None__range=(datetime(2015, 4, 7, 8, 30), datetime(2015, 9, 6, 11, 45)))
Example #6
0
 def test_filtering_skipped_with_none_value(self):
     qs = mock.Mock(spec=['filter'])
     f = DateTimeFromToRangeFilter()
     result = f.filter(qs, None)
     self.assertEqual(qs, result)
Example #7
0
 def test_filtering_start(self):
     qs = mock.Mock(spec=['filter'])
     value = mock.Mock(start=datetime(2015, 4, 7, 8, 30), stop=None)
     f = DateTimeFromToRangeFilter()
     f.filter(qs, value)
     qs.filter.assert_called_once_with(None__gte=datetime(2015, 4, 7, 8, 30))
Example #8
0
 def test_filtering_skipped_with_none_value(self):
     qs = mock.Mock(spec=['filter'])
     f = DateTimeFromToRangeFilter()
     result = f.filter(qs, None)
     self.assertEqual(qs, result)