Anonymous avatar Anonymous committed 32328a5

added test for filters

Comments (0)

Files changed (2)

+syntax: glob
 from search.core import SearchIndexField, startswith
-# TODO: add filters test to test if values only get indexed if the filter matches
 class Indexed(models.Model):
     # Test normal and prefix index
     one = models.CharField(max_length=500, null=True)
     value = models.CharField(max_length=500)
     value_index = SearchIndexField('value', integrate=('one', 'check'))
+#Test filters
+class FiltersIndexed(models.Model):
+    value = models.CharField(max_length=500)
+    check = models.BooleanField()
+    checked_index = SearchIndexField(('value', ), filters={'check':True, })
 class TestIndexed(TestCase):
     def setUp(self):
         for i in range(3):
             Indexed(one=(None, u'ÜÄÖ-+!#><|', 'blub')[i],
                     check=bool(i%2), value=u'value%d test-word' % i).save()
+        for i in range(3):
+            FiltersIndexed(check=bool(i%2), value=u'value%d test-word' % i).save()
     def test_setup(self):
         self.assertEqual(len('oneo')), 3)
         self.assertEqual(len('one')), 6)
             check__exact=False, one='blub')), 1)
+        # test filters
+        self.assertEqual(len('test-word')), 1)
     def test_change(self):
         one ='oNeone1').get() = 'oneoneone'
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
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.