comparison test/rest_common.py @ 5872:1b91e3df3fd0

Implement transitive props for sort and filter .. in REST API.
author Ralf Schlatterbeck <rsc@runtux.com>
date Mon, 26 Aug 2019 23:11:28 +0200
parents 04deafac71ab
children 6630baff5f68
comparison
equal deleted inserted replaced
5871:acc4a128ab9b 5872:1b91e3df3fd0
200 results = self.server.get_attribute( 200 results = self.server.get_attribute(
201 'user', self.joeid, 'username', self.empty_form 201 'user', self.joeid, 'username', self.empty_form
202 ) 202 )
203 self.assertEqual(self.dummy_client.response_code, 200) 203 self.assertEqual(self.dummy_client.response_code, 200)
204 self.assertEqual(results['data']['data'], 'joe') 204 self.assertEqual(results['data']['data'], 'joe')
205
206 def testGetTransitive(self):
207 """
208 Retrieve all issues with an 'o' in status
209 sort by status.name (not order)
210 """
211 base_path = self.db.config['TRACKER_WEB'] + 'rest/data/'
212 #self.maxDiff=None
213 self.create_sampledata()
214 self.db.issue.set('2', status=self.db.status.lookup('closed'))
215 self.db.issue.set('3', status=self.db.status.lookup('chatting'))
216 expected={'data':
217 {'@total_size': 2,
218 'collection': [
219 { 'id': '2',
220 'link': base_path + 'issue/2',
221 'status':
222 { 'id': '10',
223 'link': base_path + 'status/10'
224 }
225 },
226 { 'id': '1',
227 'link': base_path + 'issue/1',
228 'status':
229 { 'id': '9',
230 'link': base_path + 'status/9'
231 }
232 },
233 ]}
234 }
235 form = cgi.FieldStorage()
236 form.list = [
237 cgi.MiniFieldStorage('status.name', 'o'),
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)
205 243
206 def testOutputFormat(self): 244 def testOutputFormat(self):
207 """ test of @fields and @verbose implementation """ 245 """ test of @fields and @verbose implementation """
208 246
209 self.maxDiff = 4000 247 self.maxDiff = 4000

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