Added a test for freetext searching
FromModelWithInheritanceTest,
QueryFromIndexesTestModel,
SortKeyOnForeignKeyB,
+ T2,
TBar,
TBar2,
TBaz,
@@ -1086,6 +1087,26 @@ class TestTable(Table):
)
+@pytest.mark.django_db
+def test_freetext_searching():
+ objects = [
+ T2.objects.create(foo='q', bar='q'),
+ T2.objects.create(foo='A', bar='q'), # <- we should find this
+ T2.objects.create(foo='q', bar='a'), # <- ...and this
+ T2.objects.create(foo='w', bar='w'),
+ ]
+
+ t = Table(
+ auto__model=T2,
+ columns=dict(
+ foo__filter=dict(include=True, freetext=True),
+ bar__filter=dict(include=True, freetext=True),
+ )
+ ).bind(request=req('get', freetext_search='a'))
+
+ assert set(t.rows) == set(objects[1:-1])
+
+
@pytest.mark.django_db
def test_query_form_freetext():
class TestTable(Table):
