Skip to content

Commit f50b7da

Browse files
author
Tobias Hauth
committed
add tests for paginations
1 parent c5f1e37 commit f50b7da

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

swiftype/test_swiftype.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def test_destroy_document_type(self):
4646
def test_documents(self):
4747
self.__is_expected_collection(self.client.documents, 200, 2, {'external_id': '1'}, self.engine, self.document_type)
4848

49+
def test_documents_pagination(self):
50+
self.__is_expected_collection(self.client.documents, 200, 2, {'external_id': '1'}, self.engine, self.document_type, 2, 10)
51+
4952
def test_document(self):
5053
external_id = '1'
5154
id = self.client.document(self.engine, self.document_type, external_id)['body']['external_id']
@@ -95,29 +98,61 @@ def test_search(self):
9598
self.assertTrue(total_count > 1)
9699
self.__is_expected_search_result(self.client.search, total_count)
97100

101+
def test_search_with_options(self):
102+
total_count = len(self.client.document_types(self.engine)['body'])
103+
self.assertTrue(total_count > 1)
104+
response = self.client.search(self.engine, 'query', {'page': 2})
105+
self.assertEqual(len(response['body']['records']), total_count)
106+
98107
def test_search_document_type(self):
99108
self.__is_expected_search_result(self.client.search_document_type, 1, [self.document_type])
100109

110+
def test_search_document_type(self):
111+
response = self.client.search_document_type(self.engine, self.document_type, "query", {'page': 2})
112+
self.assertEqual(len(response['body']['records']), 1)
113+
101114
def test_suggest(self):
102115
total_count = len(self.client.document_types(self.engine)['body'])
103116
self.assertTrue(total_count > 1)
104117
self.__is_expected_search_result(self.client.suggest, total_count)
105118

119+
def test_suggest_with_options(self):
120+
total_count = len(self.client.document_types(self.engine)['body'])
121+
self.assertTrue(total_count > 1)
122+
response = self.client.suggest(self.engine, 'query', {'page': 2})
123+
self.assertEqual(len(response['body']['records']), total_count)
124+
106125
def test_suggest_document_type(self):
107126
self.__is_expected_search_result(self.client.suggest_document_type, 1, [self.document_type])
108127

128+
def test_suggest_document_type_with_options(self):
129+
response = self.client.suggest_document_type(self.engine, self.document_type, "query", {'page': 2})
130+
self.assertEqual(len(response['body']['records']), 1)
131+
109132
def test_analytics_searches(self):
110133
searches = self.client.analytics_searches(self.engine)['body']
111134
self.assertTrue(len(searches) == 1)
112135

136+
def test_analytics_searches_pagination(self):
137+
searches = self.client.analytics_searches(self.engine, '2013-01-01', '2013-02-01')['body']
138+
self.assertTrue(len(searches) == 0)
139+
113140
def test_analytics_autoselects(self):
114141
autoselects = self.client.analytics_autoselects(self.engine)['body']
115142
self.assertTrue(len(autoselects) == 1)
116143

144+
def test_analytics_autoselects_pagination(self):
145+
autoselects = self.client.analytics_autoselects(self.engine, '2013-01-01', '2013-02-01')['body']
146+
self.assertTrue(len(autoselects) == 0)
147+
117148
def test_analytics_top_queries(self):
118149
top_queries = self.client.analytics_top_queries(self.engine)['body']
119150
self.assertTrue(len(top_queries) == 2)
120151

152+
def test_analytics_top_queries(self):
153+
top_queries = self.client.analytics_top_queries(self.engine, '2013-01-01', '2013-02-01')['body']
154+
self.assertTrue(len(top_queries) == 0)
155+
121156
def test_domains(self):
122157
domains = self.client.domains(self.engine)['body']
123158
self.assertTrue(len(domains) == 2)

0 commit comments

Comments
 (0)