Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 6089:15d1ce536c73 | 6090:e097ff5064b8 |
|---|---|
| 1 import pytest | |
| 1 import unittest | 2 import unittest |
| 2 import os | 3 import os |
| 3 import shutil | 4 import shutil |
| 4 import errno | 5 import errno |
| 5 import cgi | 6 import cgi |
| 664 {'link': base_path + '1', 'status': '7', 'id': '1'}]}} | 665 {'link': base_path + '1', 'status': '7', 'id': '1'}]}} |
| 665 | 666 |
| 666 results = self.server.get_collection('issue', form) | 667 results = self.server.get_collection('issue', form) |
| 667 self.assertDictEqual(expected, results) | 668 self.assertDictEqual(expected, results) |
| 668 | 669 |
| 670 def testTransitiveField(self): | |
| 671 """ Test a transitive property in @fields """ | |
| 672 base_path = self.db.config['TRACKER_WEB'] + 'rest/data/' | |
| 673 # create sample data | |
| 674 self.create_stati() | |
| 675 self.db.issue.create( | |
| 676 title='foo4', | |
| 677 status=self.db.status.lookup('closed'), | |
| 678 priority=self.db.priority.lookup('critical') | |
| 679 ) | |
| 680 # Retrieve all issue @fields=status.name | |
| 681 form = cgi.FieldStorage() | |
| 682 form.list = [ | |
| 683 cgi.MiniFieldStorage('@fields', 'status.name') | |
| 684 ] | |
| 685 results = self.server.get_collection('issue', form) | |
| 686 self.assertEqual(self.dummy_client.response_code, 200) | |
| 687 | |
| 688 exp = [ | |
| 689 {'link': base_path + 'issue/1', 'id': '1', 'status.name': 'closed'}] | |
| 690 self.assertEqual(results['data']['collection'], exp) | |
| 691 | |
| 669 def testFilter(self): | 692 def testFilter(self): |
| 670 """ | 693 """ |
| 671 Retrieve all three users | 694 Retrieve all three users |
| 672 obtain data for 'joe' | 695 obtain data for 'joe' |
| 673 """ | 696 """ |
