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.

90 lines
3.2 KiB

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