本文整理匯總了Python中django_filters.filters.RangeFilter類的典型用法代碼示例。如果您正苦於以下問題:Python RangeFilter類的具體用法?Python RangeFilter怎麽用?Python RangeFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了RangeFilter類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_filtering_ignores_lookup_type
def test_filtering_ignores_lookup_type(self):
qs = mock.Mock()
value = mock.Mock(start=20, stop=30)
f = RangeFilter(lookup_type='gte')
f.filter(qs, value)
qs.filter.assert_called_once_with(None__range=(20, 30))
示例2: test_filtering_skipped_with_none_value
def test_filtering_skipped_with_none_value(self):
qs = mock.Mock(spec=['filter'])
f = RangeFilter()
result = f.filter(qs, None)
self.assertEqual(qs, result)
示例3: test_filtering_start
def test_filtering_start(self):
qs = mock.Mock(spec=['filter'])
value = mock.Mock(start=20, stop=None)
f = RangeFilter()
f.filter(qs, value)
qs.filter.assert_called_once_with(None__gte=20)
示例4: test_filtering
def test_filtering(self):
qs = mock.Mock(spec=['filter'])
value = mock.Mock(start=20, stop=30)
f = RangeFilter()
f.filter(qs, value)
qs.filter.assert_called_once_with(None__range=(20, 30))
示例5: test_filtering_exclude
def test_filtering_exclude(self):
qs = mock.Mock(spec=['exclude'])
value = mock.Mock(start=20, stop=30)
f = RangeFilter(exclude=True)
f.filter(qs, value)
qs.exclude.assert_called_once_with(None__range=(20, 30))