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.

52 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": "Firstname",
  14. "lastname": "Lastname",
  15. "name": "Firstname Lastname",
  16. "login": "firstname.lastname",
  17. }
  18. )
  19. def tearDown(self):
  20. super(UserCase, self).tearDown()
  21. def compare(self, copy):
  22. self.assertEqual(copy.lastname, "Lastname2")
  23. self.assertEqual(copy.firstname, "Firstname2")
  24. self.assertEqual(copy.name, "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": "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({"firstname": "Firstname2", "lastname": "Lastname2"})
  32. self.compare(copy)
  33. def test_copy_firstname_lastname_name(self):
  34. """Copy original with default firstname, lastname and name set"""
  35. copy = self.original.copy(
  36. {
  37. "firstname": "Firstname2",
  38. "lastname": "Lastname2",
  39. "name": "Firstname2 Lastname2",
  40. }
  41. )
  42. self.compare(copy)