test_website_visitor.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # -*- coding: utf-8 -*-
  2. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  3. from odoo.addons.website.tests.test_website_visitor import WebsiteVisitorTests
  4. from odoo.tests import tagged
  5. @tagged('website_visitor')
  6. class WebsiteVisitorTestsLivechat(WebsiteVisitorTests):
  7. def test_link_to_visitor_livechat(self):
  8. """ Same as parent's 'test_link_to_visitor' except we also test that conversations
  9. are merged into main visitor. """
  10. [main_visitor, linked_visitor] = self.env['website.visitor'].create([
  11. self._prepare_main_visitor_data(),
  12. self._prepare_linked_visitor_data()
  13. ])
  14. all_mail_channels = (main_visitor + linked_visitor).mail_channel_ids
  15. linked_visitor._merge_visitor(main_visitor)
  16. self.assertVisitorDeactivated(linked_visitor, main_visitor)
  17. # conversations of both visitors should be merged into main one
  18. self.assertEqual(len(main_visitor.mail_channel_ids), 2)
  19. self.assertEqual(main_visitor.mail_channel_ids, all_mail_channels)
  20. def _prepare_main_visitor_data(self):
  21. values = super()._prepare_main_visitor_data()
  22. test_partner = self.env['res.partner'].create({'name': 'John Doe'})
  23. values.update({
  24. 'partner_id': test_partner.id,
  25. 'mail_channel_ids': [(0, 0, {
  26. 'name': 'Conversation 1'
  27. })]
  28. })
  29. return values
  30. def _prepare_linked_visitor_data(self):
  31. values = super()._prepare_linked_visitor_data()
  32. values.update({
  33. 'mail_channel_ids': [(0, 0, {
  34. 'name': 'Conversation 2'
  35. })]
  36. })
  37. return values