comparison test/rest_common.py @ 5874:6630baff5f68

Implement exact string search in REST API Now with ':=' instead of '=' an exact string match is requested. In addition we now support '~=' for a substring search. The old semantics of '=' is kept. The new syntax works for all types of properties but only makes a difference for String properties. Note that this is not yet documented, pending discussion if we want to keep this syntax.
author Ralf Schlatterbeck <rsc@runtux.com>
date Tue, 27 Aug 2019 18:37:18 +0200
parents 1b91e3df3fd0
children 1b57d8f3eb97
comparison
equal deleted inserted replaced
5873:14f5c3179711 5874:6630baff5f68
234 } 234 }
235 form = cgi.FieldStorage() 235 form = cgi.FieldStorage()
236 form.list = [ 236 form.list = [
237 cgi.MiniFieldStorage('status.name', 'o'), 237 cgi.MiniFieldStorage('status.name', 'o'),
238 cgi.MiniFieldStorage('@fields', 'status'), 238 cgi.MiniFieldStorage('@fields', 'status'),
239 cgi.MiniFieldStorage('@sort', 'status.name'),
240 ]
241 results = self.server.get_collection('issue', form)
242 self.assertDictEqual(expected, results)
243
244 def testGetExactMatch(self):
245 """ Retrieve all issues with an exact title
246 """
247 base_path = self.db.config['TRACKER_WEB'] + 'rest/data/'
248 #self.maxDiff=None
249 self.create_sampledata()
250 self.db.issue.set('2', title='This is an exact match')
251 self.db.issue.set('3', title='This is an exact match')
252 self.db.issue.set('1', title='This is AN exact match')
253 expected={'data':
254 {'@total_size': 2,
255 'collection': [
256 { 'id': '2',
257 'link': base_path + 'issue/2',
258 },
259 { 'id': '3',
260 'link': base_path + 'issue/3',
261 },
262 ]}
263 }
264 form = cgi.FieldStorage()
265 form.list = [
266 cgi.MiniFieldStorage('title:', 'This is an exact match'),
239 cgi.MiniFieldStorage('@sort', 'status.name'), 267 cgi.MiniFieldStorage('@sort', 'status.name'),
240 ] 268 ]
241 results = self.server.get_collection('issue', form) 269 results = self.server.get_collection('issue', form)
242 self.assertDictEqual(expected, results) 270 self.assertDictEqual(expected, results)
243 271

Roundup Issue Tracker: http://roundup-tracker.org/