partner-contact/partner_firstname/tests/test_copy.py

53 lines
1.7 KiB
Python
Raw Normal View History

2021-03-23 19:13:18 +00:00
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
"""Test copy function for models."""
from flectra.tests.common import TransactionCase
from .base import MailInstalled
class UserCase(TransactionCase, MailInstalled):
"""Test ``res.users``."""
def setUp(self):
super(UserCase, self).setUp()
self.create_original()
def create_original(self):
self.original = self.env["res.users"].create(
{
2022-06-29 18:38:32 +00:00
"firstname": "Firstname",
"lastname": "Lastname",
"name": "Firstname Lastname",
"login": "firstname.lastname",
2021-03-23 19:13:18 +00:00
}
)
def tearDown(self):
super(UserCase, self).tearDown()
def compare(self, copy):
2022-06-29 18:38:32 +00:00
self.assertEqual(copy.lastname, "Lastname2")
self.assertEqual(copy.firstname, "Firstname2")
self.assertEqual(copy.name, "Firstname2 Lastname2")
2021-03-23 19:13:18 +00:00
def test_copy_name(self):
"""Copy original with default name set - firstname lastname not set."""
2022-06-29 18:38:32 +00:00
copy = self.original.copy({"name": "Firstname2 Lastname2"})
2021-03-23 19:13:18 +00:00
self.compare(copy)
def test_copy_firstname_lastname(self):
"""Copy original with default firstname and lastname set"""
2022-06-29 18:38:32 +00:00
copy = self.original.copy({"firstname": "Firstname2", "lastname": "Lastname2"})
2021-03-23 19:13:18 +00:00
self.compare(copy)
def test_copy_firstname_lastname_name(self):
"""Copy original with default firstname, lastname and name set"""
copy = self.original.copy(
{
2022-06-29 18:38:32 +00:00
"firstname": "Firstname2",
"lastname": "Lastname2",
"name": "Firstname2 Lastname2",
2021-03-23 19:13:18 +00:00
}
)
self.compare(copy)