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.

54 lines
1.7 KiB

  1. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  2. """Test copy function for models."""
  3. from odoo.tests.common import TransactionCase
  4. from .base import MailInstalled
  5. class UserCase(TransactionCase, MailInstalled):
  6. """Test ``res.users``."""
  7. def setUp(self):
  8. super(UserCase, self).setUp()
  9. self.create_original()
  10. def create_original(self):
  11. self.original = self.env["res.users"].create(
  12. {
  13. "firstname": u"Firstname",
  14. "lastname": u"Lastname",
  15. "name": u"Firstname Lastname",
  16. "login": u"firstname.lastname",
  17. }
  18. )
  19. def tearDown(self):
  20. super(UserCase, self).tearDown()
  21. def compare(self, copy):
  22. self.assertEqual(copy.lastname, u"Lastname2")
  23. self.assertEqual(copy.firstname, u"Firstname2")
  24. self.assertEqual(copy.name, u"Firstname2 Lastname2")
  25. def test_copy_name(self):
  26. """Copy original with default name set - firstname lastname not set."""
  27. copy = self.original.copy({"name": u"Firstname2 Lastname2"})
  28. self.compare(copy)
  29. def test_copy_firstname_lastname(self):
  30. """Copy original with default firstname and lastname set"""
  31. copy = self.original.copy(
  32. {"firstname": u"Firstname2", "lastname": u"Lastname2"}
  33. )
  34. self.compare(copy)
  35. def test_copy_firstname_lastname_name(self):
  36. """Copy original with default firstname, lastname and name set"""
  37. copy = self.original.copy(
  38. {
  39. "firstname": u"Firstname2",
  40. "lastname": u"Lastname2",
  41. "name": u"Firstname2 Lastname2",
  42. }
  43. )
  44. self.compare(copy)