From 3b3279c77e2b656422d55216429439bd1de15b3b Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 7 Sep 2012 12:44:48 +0200 Subject: [PATCH] [FIX] orm: adapt tests of method resolve_2many_commands bzr revid: rco@openerp.com-20120907104448-9b9aeenmqz5m5du2 --- openerp/tests/test_orm.py | 40 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/openerp/tests/test_orm.py b/openerp/tests/test_orm.py index 8c7043a5ff0..f04b9d77747 100644 --- a/openerp/tests/test_orm.py +++ b/openerp/tests/test_orm.py @@ -93,6 +93,23 @@ class TestO2MSerialization(common.TransactionCase): {'id': id_baz, 'name': 'quux', 'city': 'tag'} ]) + def test_DELETE_command(self): + " deleted records are not returned at all. " + ids = [ + self.partner.create(self.cr, UID, {'name': 'foo'}), + self.partner.create(self.cr, UID, {'name': 'bar'}), + self.partner.create(self.cr, UID, {'name': 'baz'}) + ] + commands = [DELETE(ids[0]), DELETE(ids[1]), DELETE(ids[2])] + + results = self.partner.resolve_2many_commands( + self.cr, UID, 'address', commands, ['name']) + + self.assertEqual(results, [ + {'id': ids[0], 'name': 'foo'}, + {'id': ids[2], 'name': 'baz'} + ]) + def test_mixed_commands(self): ids = [ self.partner.create(self.cr, UID, {'name': name}) @@ -104,7 +121,7 @@ class TestO2MSerialization(common.TransactionCase): CREATE({'name': 'foo'}), UPDATE(ids[0], {'name': 'bar'}), LINK_TO(ids[1]), - LINK_TO(ids[2]), + DELETE(ids[2]), UPDATE(ids[3], {'name': 'quux',}), UPDATE(ids[4], {'name': 'corge'}), CREATE({'name': 'grault'}), @@ -115,7 +132,6 @@ class TestO2MSerialization(common.TransactionCase): {'name': 'foo'}, {'id': ids[0], 'name': 'bar'}, {'id': ids[1], 'name': 'baz'}, - {'id': ids[2], 'name': 'qux'}, {'id': ids[3], 'name': 'quux'}, {'id': ids[4], 'name': 'corge'}, {'name': 'grault'}, @@ -150,24 +166,4 @@ class TestO2MSerialization(common.TransactionCase): # 5 should fail with an assert error, but not e.g. a ValueError pass - def test_invalid_commands(self): - "Commands with uncertain semantics in this context should be forbidden" - - with self.assertRaises(AssertionError): - self.partner.resolve_2many_commands( - self.cr, UID, 'address', [DELETE(42)], ['name']) - - with self.assertRaises(AssertionError): - self.partner.resolve_2many_commands( - self.cr, UID, 'address', [FORGET(42)], ['name']) - - with self.assertRaises(AssertionError): - self.partner.resolve_2many_commands( - self.cr, UID, 'address', [DELETE_ALL()], ['name']) - - with self.assertRaises(AssertionError): - self.partner.resolve_2many_commands( - self.cr, UID, 'address', [REPLACE_WITH([42])], ['name']) - - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: