django-easyfilters / django_easyfilters / tests / filterset.py

Diff from to

django_easyfilters/tests/filterset.py

         """
         Tests that in the case produced in test_datetime_filter_drill_down_to_choice,
         the remove links display correctly.
-        down to reach it.
         """
         # Two birthdays in Jan 2011
         Person.objects.create(name="Joe", date_of_birth=date(2011, 1, 10))
                           ],
                          [(c.label, c.link_type) for c in choices])
 
+    def test_datetime_filter_bridge_from_multi_to_single(self):
+        """
+        Tests that bridge_choices will bridge from range (multi) choices to
+        single choices.
+        """
+        # Two birthdays in Jan 2011
+        Person.objects.create(name="Joe", date_of_birth=date(2011, 1, 10))
+        Person.objects.create(name="Peter", date_of_birth=date(2011, 1, 20))
+
+        # Chosen year = 2010 - 2011
+        params = MultiValueDict({'date_of_birth':['2010..2011']})
+
+        f = DateTimeFilter('date_of_birth', Person, params)
+        qs = Person.objects.all()
+        qs_filtered = f.apply_filter(qs)
+        choices = f.get_choices(qs_filtered)
+
+        # Expect 2010 - 2011 as remove link
+        self.assertEqual(['2010-2011'], [c.label for c in choices if c.link_type == FILTER_REMOVE])
+        # Expect 2011 and January as display
+        self.assertEqual(['2011', 'January'], [c.label for c in choices if c.link_type == FILTER_DISPLAY])
+        # Expect '10' and '20' as choices
+        self.assertEqual(['10', '20'], [c.label for c in choices if c.link_type == FILTER_ADD])
+
     def test_numericrange_filter_simple_vals(self):
         # If data is less than max_links, we should get a simple list of values.
         filter1 = NumericRangeFilter('price', Book, MultiValueDict(), max_links=20)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.