diff options
Diffstat (limited to 'odoo/addons/test_new_api/tests/test_attributes.py')
| -rw-r--r-- | odoo/addons/test_new_api/tests/test_attributes.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/odoo/addons/test_new_api/tests/test_attributes.py b/odoo/addons/test_new_api/tests/test_attributes.py new file mode 100644 index 00000000000..c8cceb69210 --- /dev/null +++ b/odoo/addons/test_new_api/tests/test_attributes.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from openerp.tests import common + +ANSWER_TO_ULTIMATE_QUESTION = 42 + +class TestAttributes(common.TransactionCase): + + def test_we_can_add_attributes(self): + Model = self.env['test_new_api.category'] + instance = Model.create({'name': 'Foo'}) + + # assign an unknown attribute + instance.unknown = ANSWER_TO_ULTIMATE_QUESTION + + # Does the attribute exist in the instance of the model ? + self.assertTrue(hasattr(instance, 'unknown')) + + # Is it the right type ? + self.assertIsInstance(instance.unknown, (int, long)) + + # Is it the right value, in case of, we don't know ;-) + self.assertEqual(instance.unknown, ANSWER_TO_ULTIMATE_QUESTION) + + # We are paranoiac ! + self.assertEqual(getattr(instance, 'unknown'), ANSWER_TO_ULTIMATE_QUESTION) |
