diff test/rest_common.py @ 6256:29c6dc8ed004

Test handling of unset transitive link field. Test changeset p5b66c480f71f by adding a new link to issue to the user class. Without the changeset, modifying testGetTransitive to include: cgi.MiniFieldStorage('@fields', 'status,assignedto.issue') results in: {'error': {'status': 404, 'msg': IndexError('no such user None',)}} (Note this is the wrong error message, it's not user that is None, it's None value for the issue link in the user object.) With the changeset and modfying expected output to include the new field, I get a passing test with output like: { 'id': '2', 'link': base_path + 'issue/2', 'assignedto.issue': None, 'status': { 'id': '10', 'link': base_path + 'status/10' } }, Changing the schema also requires changes to the etag testing code since it uses the user object and the representation has changed.
author John Rouillard <rouilj@ieee.org>
date Thu, 20 Aug 2020 23:28:24 -0400
parents 1cb2375015f0
children be8d5a8e090a
line wrap: on
line diff
--- a/test/rest_common.py	Tue Aug 18 09:19:03 2020 +0200
+++ b/test/rest_common.py	Thu Aug 20 23:28:24 2020 -0400
@@ -215,6 +215,7 @@
         self.db.issue.addprop(afloat=hyperdb.Number())
         self.db.issue.addprop(abool=hyperdb.Boolean())
         self.db.issue.addprop(requireme=hyperdb.String(required=True))
+        self.db.user.addprop(issue=hyperdb.Link('issue'))
         self.db.msg.addprop(tx_Source=hyperdb.String())
 
         self.db.post_init()
@@ -359,6 +360,7 @@
                     'collection': [
                       { 'id': '2',
                         'link': base_path + 'issue/2',
+                        'assignedto.issue': None,
                         'status':
                           { 'id': '10',
                             'link': base_path + 'status/10'
@@ -366,6 +368,7 @@
                       },
                       { 'id': '1',
                         'link': base_path + 'issue/1',
+                        'assignedto.issue': None,
                         'status':
                           { 'id': '9',
                             'link': base_path + 'status/9'
@@ -376,7 +379,7 @@
         form = cgi.FieldStorage()
         form.list = [
             cgi.MiniFieldStorage('status.name', 'o'),
-            cgi.MiniFieldStorage('@fields', 'status'),
+            cgi.MiniFieldStorage('@fields', 'status,assignedto.issue'),
             cgi.MiniFieldStorage('@sort', 'status.name'),
         ]
         results = self.server.get_collection('issue', form)
@@ -1139,14 +1142,14 @@
             items = node.items(protected=True) # include every item
             print(repr(sorted(items)))
             print(etag)
-            self.assertEqual(etag, '"0433784660a141e8262835171e70fd2f"')
+            self.assertEqual(etag, '"07c3a7f214d394cf46220e294a5a53c8"')
 
             # modify key and verify we have a different etag
             etag = calculate_etag(node, self.db.config['WEB_SECRET_KEY'] + "a")
             items = node.items(protected=True) # include every item
             print(repr(sorted(items)))
             print(etag)
-            self.assertNotEqual(etag, '"0433784660a141e8262835171e70fd2f"')
+            self.assertNotEqual(etag, '"07c3a7f214d394cf46220e294a5a53c8"')
 
             # change data and verify we have a different etag
             node.username="Paul"
@@ -1154,7 +1157,7 @@
             items = node.items(protected=True) # include every item
             print(repr(sorted(items)))
             print(etag)
-            self.assertEqual(etag, '"8abeacd284d58655c620d60389e29d4d"')
+            self.assertEqual(etag, '"d655801d3a6d51e32891531b06ccecfa"')
         finally:
             date.Date = originalDate
         

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