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.

71 lines
2.7 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Antiun Ingeniería S.L. - Jairo Llopis
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp.tests.common import TransactionCase
  5. class SignatureCase(TransactionCase):
  6. def setUp(self):
  7. super(SignatureCase, self).setUp()
  8. self.user = self.env.ref("base.user_demo").with_context(lang="en_US")
  9. self.mail_notification = self.env["mail.notification"].with_context(
  10. lang="en_US")
  11. def signature(self, **context):
  12. """Get user's signature."""
  13. return (self.mail_notification.with_context(**context)
  14. ._get_signature_footer(self.user.id))
  15. def test_signature_user_custom(self):
  16. """User name does not appear in signature when it is custom."""
  17. self.user.signature = u"¡Cüstom!"
  18. signature = self.signature()
  19. self.assertNotIn(self.user.name, signature)
  20. def test_signature_user_empty(self):
  21. """User name appears in signature by default."""
  22. self.user.signature = False
  23. signature = self.signature()
  24. self.assertIn(self.user.name, signature)
  25. def test_signature_user_skip(self):
  26. """User signature is skipped."""
  27. self.user.signature = "Skip me."
  28. signature = self.signature(skip_signature_user=True)
  29. self.assertNotIn(self.user.signature, signature)
  30. def test_signature_company_website_custom(self):
  31. """Company website link appears in signature."""
  32. sites = (
  33. "HTTP://EXAMPLE.COM",
  34. "http://example.com",
  35. "https://example.com",
  36. "HTTPS://example.com,"
  37. )
  38. for site in sites:
  39. for url in (site, site[8:]):
  40. self.user.company_id.website = url
  41. signature = self.signature()
  42. self.assertIn(url, signature)
  43. self.assertIn(self.user.company_id.name, signature)
  44. def test_signature_company_website_empty(self):
  45. """Company website link does not appear in signature."""
  46. self.user.company_id.website = False
  47. signature = self.signature()
  48. self.assertNotIn("<a href", signature)
  49. self.assertIn(self.user.company_id.name, signature)
  50. def test_signature_company_skip(self):
  51. """Company signature is skipped."""
  52. self.user.company_id.website = "http://example.com"
  53. signature = self.signature(skip_signature_company=True)
  54. self.assertNotIn(self.user.company_id.website, signature)
  55. def test_unbranded(self):
  56. """No Odoo branding found."""
  57. signature = self.signature()
  58. self.assertNotIn("using", signature)
  59. self.assertNotIn("odoo.com", signature)
  60. self.assertNotIn("Odoo", signature)