You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp import fields
  5. from openerp.tests.common import TransactionCase
  6. from datetime import date
  7. class GoodCase(TransactionCase):
  8. def setUp(self):
  9. super(GoodCase, self).setUp()
  10. self.partner = self.env["res.partner"].create({"name": str(self)})
  11. self.birthdate = date.today()
  12. def tearDown(self):
  13. self.assertEqual(self.partner.birthdate, self.partner.birthdate_date)
  14. super(GoodCase, self).tearDown()
  15. def test_new_to_old(self):
  16. self.partner.birthdate_date = self.birthdate
  17. def test_old_to_new(self):
  18. self.partner.birthdate = fields.Date.to_string(self.birthdate)
  19. class BadCase(TransactionCase):
  20. def setUp(self):
  21. super(BadCase, self).setUp()
  22. self.partner = self.env["res.partner"].create({"name": str(self)})
  23. def test_old_to_new(self):
  24. with self.assertRaises(ValueError):
  25. self.partner.birthdate = "Not a date"