-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathintegration_test_string_filtering.py
More file actions
35 lines (26 loc) · 1.21 KB
/
integration_test_string_filtering.py
File metadata and controls
35 lines (26 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
from syncano.models import Object
from tests.integration_test import InstanceMixin, IntegrationTest
class StringFilteringTest(InstanceMixin, IntegrationTest):
@classmethod
def setUpClass(cls):
super(StringFilteringTest, cls).setUpClass()
cls.klass = cls.instance.classes.create(name='class_a',
schema=[{'name': 'title', 'type': 'string', 'filter_index': True}])
cls.object = cls.klass.objects.create(title='Some great title')
def _test_filter(self, filter):
filtered_obj = Object.please.list(class_name='class_a').filter(
**filter
).first()
self.assertTrue(filtered_obj.id)
def test_starstwith(self):
self._test_filter({'title__startswith': 'Some'})
self._test_filter({'title__istartswith': 'some'})
def test_endswith(self):
self._test_filter({'title__endswith': 'tle'})
self._test_filter({'title__iendswith': 'TLE'})
def test_contains(self):
self._test_filter({'title__contains': 'gre'})
self._test_filter({'title__icontains': 'gRe'})
def test_eq(self):
self._test_filter({'title__ieq': 'some gREAt title'})