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