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.

53 lines
1.8 KiB

  1. # -*- coding: utf-8 -*-
  2. # Odoo, Open Source Management Solution
  3. # Copyright (C) 2014-2015 Grupo ESOC <www.grupoesoc.es>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU Affero General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Affero General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. from openerp import fields
  18. from openerp.tests.common import TransactionCase
  19. from datetime import date
  20. class GoodCase(TransactionCase):
  21. def setUp(self):
  22. super(GoodCase, self).setUp()
  23. self.partner = self.env["res.partner"].create({"name": str(self)})
  24. self.birthdate = date.today()
  25. def tearDown(self):
  26. self.assertEqual(self.partner.birthdate, self.partner.birthdate_date)
  27. super(GoodCase, self).tearDown()
  28. def test_new_to_old(self):
  29. self.partner.birthdate_date = self.birthdate
  30. def test_old_to_new(self):
  31. self.partner.birthdate = fields.Date.to_string(self.birthdate)
  32. class BadCase(TransactionCase):
  33. def setUp(self):
  34. super(BadCase, self).setUp()
  35. self.partner = self.env["res.partner"].create({"name": str(self)})
  36. self.birthdate = date.today()
  37. def tearDown(self):
  38. self.assertNotEqual(self.partner.birthdate,
  39. self.partner.birthdate_date)
  40. super(BadCase, self).tearDown()
  41. def test_old_to_new(self):
  42. self.partner.birthdate = "Not a date"