Skip to content

Commit 6a16728

Browse files
committed
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.
1 parent a61da93 commit 6a16728

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/rest_common.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def setUp(self):
215215
self.db.issue.addprop(afloat=hyperdb.Number())
216216
self.db.issue.addprop(abool=hyperdb.Boolean())
217217
self.db.issue.addprop(requireme=hyperdb.String(required=True))
218+
self.db.user.addprop(issue=hyperdb.Link('issue'))
218219
self.db.msg.addprop(tx_Source=hyperdb.String())
219220

220221
self.db.post_init()
@@ -359,13 +360,15 @@ def testGetTransitive(self):
359360
'collection': [
360361
{ 'id': '2',
361362
'link': base_path + 'issue/2',
363+
'assignedto.issue': None,
362364
'status':
363365
{ 'id': '10',
364366
'link': base_path + 'status/10'
365367
}
366368
},
367369
{ 'id': '1',
368370
'link': base_path + 'issue/1',
371+
'assignedto.issue': None,
369372
'status':
370373
{ 'id': '9',
371374
'link': base_path + 'status/9'
@@ -376,7 +379,7 @@ def testGetTransitive(self):
376379
form = cgi.FieldStorage()
377380
form.list = [
378381
cgi.MiniFieldStorage('status.name', 'o'),
379-
cgi.MiniFieldStorage('@fields', 'status'),
382+
cgi.MiniFieldStorage('@fields', 'status,assignedto.issue'),
380383
cgi.MiniFieldStorage('@sort', 'status.name'),
381384
]
382385
results = self.server.get_collection('issue', form)
@@ -1139,22 +1142,22 @@ def dummyClosure(adate=None, translator=None):
11391142
items = node.items(protected=True) # include every item
11401143
print(repr(sorted(items)))
11411144
print(etag)
1142-
self.assertEqual(etag, '"0433784660a141e8262835171e70fd2f"')
1145+
self.assertEqual(etag, '"07c3a7f214d394cf46220e294a5a53c8"')
11431146

11441147
# modify key and verify we have a different etag
11451148
etag = calculate_etag(node, self.db.config['WEB_SECRET_KEY'] + "a")
11461149
items = node.items(protected=True) # include every item
11471150
print(repr(sorted(items)))
11481151
print(etag)
1149-
self.assertNotEqual(etag, '"0433784660a141e8262835171e70fd2f"')
1152+
self.assertNotEqual(etag, '"07c3a7f214d394cf46220e294a5a53c8"')
11501153

11511154
# change data and verify we have a different etag
11521155
node.username="Paul"
11531156
etag = calculate_etag(node, self.db.config['WEB_SECRET_KEY'])
11541157
items = node.items(protected=True) # include every item
11551158
print(repr(sorted(items)))
11561159
print(etag)
1157-
self.assertEqual(etag, '"8abeacd284d58655c620d60389e29d4d"')
1160+
self.assertEqual(etag, '"d655801d3a6d51e32891531b06ccecfa"')
11581161
finally:
11591162
date.Date = originalDate
11601163

0 commit comments

Comments
 (0)