Mercurial > p > roundup > code
diff test/rest_common.py @ 6090:e097ff5064b8
Allow transitive properties in @fields in REST API
These transitive properties may not cross Multilinks, e.g., when
querying 'issue' the property 'messages.author' is not allowed (because
'messages' is a multilink). A multilink at the end (e.g. messages in the
example) is fine.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Thu, 13 Feb 2020 08:51:20 +0100 |
| parents | a0ab2c5d1c2a |
| children | 1cb2375015f0 |
line wrap: on
line diff
--- a/test/rest_common.py Wed Feb 12 17:25:39 2020 +0100 +++ b/test/rest_common.py Thu Feb 13 08:51:20 2020 +0100 @@ -1,3 +1,4 @@ +import pytest import unittest import os import shutil @@ -666,6 +667,28 @@ results = self.server.get_collection('issue', form) self.assertDictEqual(expected, results) + def testTransitiveField(self): + """ Test a transitive property in @fields """ + base_path = self.db.config['TRACKER_WEB'] + 'rest/data/' + # create sample data + self.create_stati() + self.db.issue.create( + title='foo4', + status=self.db.status.lookup('closed'), + priority=self.db.priority.lookup('critical') + ) + # Retrieve all issue @fields=status.name + form = cgi.FieldStorage() + form.list = [ + cgi.MiniFieldStorage('@fields', 'status.name') + ] + results = self.server.get_collection('issue', form) + self.assertEqual(self.dummy_client.response_code, 200) + + exp = [ + {'link': base_path + 'issue/1', 'id': '1', 'status.name': 'closed'}] + self.assertEqual(results['data']['collection'], exp) + def testFilter(self): """ Retrieve all three users
