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.

88 lines
3.1 KiB

6 years ago
  1. # Authors: Nemry Jonathan
  2. # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
  3. # All Rights Reserved
  4. #
  5. # WARNING: This program as such is intended to be used by professional
  6. # programmers who take the whole responsibility of assessing all potential
  7. # consequences resulting from its eventual inadequacies and bugs.
  8. # End users who are looking for a ready-to-use solution with commercial
  9. # guarantees and support are strongly advised to contact a Free Software
  10. # Service Company.
  11. #
  12. # This program is Free Software; you can redistribute it and/or
  13. # modify it under the terms of the GNU General Public License
  14. # as published by the Free Software Foundation; either version 2
  15. # of the License, or (at your option) any later version.
  16. #
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with this program; if not, write to the Free Software
  24. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  25. """Test naming logic.
  26. To have more accurate results, remove the ``mail`` module before testing.
  27. """
  28. from .base import BaseCase
  29. class PartnerContactCase(BaseCase):
  30. def test_update_lastname(self):
  31. """Change lastname."""
  32. self.expect("newlästname", self.firstname)
  33. self.original.name = self.name
  34. def test_update_firstname(self):
  35. """Change firstname."""
  36. self.expect(self.lastname, "newfïrstname")
  37. self.original.name = self.name
  38. def test_whitespace_cleanup(self):
  39. """Check that whitespace in name gets cleared."""
  40. self.expect("newlästname", "newfïrstname")
  41. self.original.name = " newfïrstname newlästname "
  42. # Need this to refresh the ``name`` field
  43. self.original.invalidate_cache(["name"])
  44. class PartnerCompanyCase(BaseCase):
  45. def create_original(self):
  46. super(PartnerCompanyCase, self).create_original()
  47. self.original.is_company = True
  48. def test_copy(self):
  49. """Copy the partner and compare the result."""
  50. super(PartnerCompanyCase, self).test_copy()
  51. self.expect(self.name, False, self.name)
  52. def test_company_inverse(self):
  53. """Test the inverse method in a company record."""
  54. name = "Thïs is a Companŷ"
  55. self.expect(name, False, name)
  56. self.original.name = name
  57. class UserCase(PartnerContactCase):
  58. def create_original(self):
  59. name = "{} {}".format(self.firstname, self.lastname)
  60. # Cannot create users if ``mail`` is installed
  61. if self.mail_installed():
  62. self.original = self.env.ref("base.user_demo")
  63. self.original.name = name
  64. else:
  65. self.original = self.env["res.users"].create(
  66. {"name": name, "login": "firstnametest@example.com"}
  67. )
  68. def test_copy(self):
  69. """Copy the partner and compare the result."""
  70. # Skip if ``mail`` is installed
  71. if not self.mail_installed():
  72. super(UserCase, self).test_copy()