[IMP] test_new_api: add list view for participants in discussion form view

This is for testing the result of an `onchange` that returns a many2many field.
This commit is contained in:
Raphael Collet
2015-11-23 10:20:31 +01:00
parent 86d24996d9
commit 954f516fde
2 changed files with 13 additions and 5 deletions
@@ -133,7 +133,10 @@ class TestOnChange(common.TransactionCase):
field_onchange = self.Discussion._onchange_spec()
self.assertEqual(field_onchange.get('moderator'), '1')
self.assertFalse(any(name.startswith('participants.') for name in field_onchange))
self.assertItemsEqual(
strip_prefix('participants.', field_onchange),
['display_name'],
)
# first remove demo user from participants
discussion.participants -= demo
@@ -151,9 +154,10 @@ class TestOnChange(common.TransactionCase):
result = discussion.onchange(values, 'moderator', field_onchange)
self.assertIn('participants', result['value'])
self.assertEqual(
self.assertItemsEqual(
result['value']['participants'],
[(5,)] + [(4, usr.id) for usr in discussion.participants + demo],
[(5,)] + [(1, user.id, {'display_name': user.display_name})
for user in discussion.participants + demo],
)
def test_onchange_one2many_value(self):
+6 -2
View File
@@ -49,7 +49,7 @@
<notebook>
<page string="Messages">
<field name="messages">
<tree name="Messages">
<tree string="Messages">
<field name="name"/>
<field name="body"/>
</tree>
@@ -65,7 +65,11 @@
</field>
</page>
<page string="Participants">
<field name="participants"/>
<field name="participants">
<tree string="Participants">
<field name="display_name"/>
</tree>
</field>
</page>
</notebook>
<group>