summaryrefslogtreecommitdiff
path: root/addons/test_mail_full/tests/common.py
AgeCommit message (Collapse)Author
2021-05-21[IMP] test_mail_full: add test for SMS mailing default domain and optoutThibault Delavallée
Purpose is to test specific behavior of opt-out for SMS marketing. This is currently not tested and working a bit strangely, as they are flagged as blacklist. This will soon be updated in another task but at least current behavior is logged somewhere. We also update some test models in order to reflect potential strange and non-default behavior, notably partner_id field used as contact field. It will be used soon when cleaning some opt-out behavior. Tests are added to check phone sanitized is correctly taken into account in default domains when inheriting from the phone blacklist mixin. Some counters notes are also updated next to some last updates. Task ID-2431217 COM PR odoo/odoo#71140
2020-11-26[IMP] test_mail: add new mail composer tests for its internalsThibault Delavallée
Purpose is to have some low level tests for composer itself allowing to ensure its behavior. We add tests notably about default values computation in mass mailing mode as well as template_id change and values synchronization in composer model. In a near future composer will probably be improved (use computed fields, rewrite part of its logic to improve performances). Having tests done before those tasks ensure we notice every change that might happen. Task ID-2390314 PR odoo/odoo#62061
2020-08-05[FIX] test_mail_full, test_mass_mailing: fix some tool methodsThibault Delavallée
Small improvements / fixes in tool methods used in python unit tests. Task ID-2239327 Task ID-2239327 PR #49886
2020-05-26[IMP] (test_)(mass_)mail(_full): rename and reorganize mail related test classesThibault Delavallée
Modules holding tests and helpers * link_tracker: mainly mock, asserts and tools for link tracker tests (MockLinkTracker); * mail: mainly gateway mock and base for mail tests * MockEmail -> mocks for mail gateway; * MailCase -> tools and asserts for mail tests; * MailCommon -> base for mail functional tests); * sms: mainly SMS gateway mock and base for sms tests * MockSMS -> mocks for SMS gateway; * SMS Case -> tools and asserts for mail / SMS tests; * SMSCommon -> update of MailCommon with SMS capabilities); * mass_mailing: mainly asserts and tools for mass mailing tests * MassMailCase -> update of MailCase for mass mailing tools and asserts; * MassMailCommon -> update of MailCommon with mass mailing); * mass_mailing_sms: mainly asserts and tools for mass SMS tests * MockMassSMS -> update of MockSMS for mass SMS tools and asserts; * MassSMSCommon -> update of MassMailCommon with SMS capabilities); Modules for tests * test_mail: module for mail app tests (TestMailCommon); * test_mass_mailing: module for mass mailing app tests (TestMassMailCommon); * test_mail_full: tests integrating all discuss features, currently mainly mail and SMS (TestMailFullCommon); Enterprise: update test_mail_enterprise and test_marketing_automation Task ID 2247037 Community PR odoo/odoo#50384 Enterprise PR odoo/enterprise#10266 Upgrade PR odoo/upgrade#1122
2020-04-24[IMP] link_tracker, (test_)mass_mailing: improve test tools and clean ↵Thibault Delavallée
existing tests URPOSE Prepare code cleaning and optimization in mail, mass_mailing and SMS by cleaning models for readability and code complexity and footprint reduction. SPECIFICATIONS Add tool methods and asserts for link tracker tests. Add tool methods and assets for mass mailing tests, notably about mailing traces and their link with emails. Merge existing and duplicated tests and rewrite them a bit. Rename and improve test_mass_mailing models. LINKS Prepares task ID 2238597 (notification and trace models cleaning) Task ID 1906925 (mass mailing tests cleaning) PR #50169 Related: odoo/enterprise#10180 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-11-20[REF] test_mail_full: update module to new commonThibault Delavallée
PURPOSE Currently tools and asserts for mail tests are located inside test_mail module. It makes difficult to re-use them in apps tests or force them to write custom quick and dirty tools and asserts. SPECIFICATIONS Update this module to new tools / asserts / helpers / classes defined in mail and test_mail. In this commit we remove the ``BaseFunctionalTest`` and replace it by a fresh ``TestSMSCommon`` that is the combination of ``TestMailCommon`` from mail and mass mailing with SMS mocks capabilities. That way all mocks and asserts are available in all sub test classes. ``MassSMSBaseFunctionalTest`` is not necessary anymore as everything is available directly with ``TestSMSCommon``. Coming from common update, we have notably * ``BaseFunctionalTest`` class is replaced by the new ``TestMailCommon`` pimped one; * ``assertNotifications`` is replaced by ``assertSinglePostNotifications`` (shortcut for a simple message_post) or ``assertPostNotifications`` (complete asserts involving several messages and notifications); * correctly invoke ``mock_mail_gateway`` when mocking email sending; * replace manual check of sent emails or ``assertEmails`` by ``assertSentEmails``; * remove custom mocks / checks and replace them by now standard mocks and assertions (if any); LINKS Task ID 2068986 PR #38070
2019-08-12[ADD] mass_mailing_sms: support SMS in mass mailingThibault Delavallée
PURPOSE SMS are a powerful marketing tool. For instance it is perfect to announce a sale or to communicate a coupon code, to welcome a new customer in a fidelity program, ... Purpose of this task is to integrate SMS sending in batch in mass mailing. It will use same mailing objects but sending SMS instead of emails. Some metrics and flows will have to be slightly updated at the same time. SPECIFICATIONS Create a new application called "Mass SMS" that follows the structure of mass_mailing application. General guidelines * use the fa-comment icon for this module; * add a "Notification type" field to the mailings: email or sms. Set it invisible and set as domain from context when choosing mass mailing or mass sms application (menus / action specific); * adapt the metrics from Mass Mailing to SMS * sent = received = whether the SMS was sent or not; * opened => we don't have this information; * replied => we don't have this information; * clicks = from link tracker (no change of behavior); * bounced = SMS that failed to be delivered because the format is wrong; * exception = any issue when sending SMS; * keep the Mailing Lists menu, hide email related fields on contact model; * settings: hide the "Specific Mail Server" feature Mailing form view * add an "SMS Content" tab between Mail Body and Options. In there, we should have the following fields: * content * opt-out link: provide a link to the Unsubscribe page. Make it as short as possible; * SMS Template * add an "SMS Text Message" Medium; Mailing actions * add an "SMS Sent" smart button. Use the fa-comment-o icon and it should redirect to the same list views as the "Email sent" smart button and list the contacts to which an SMS was sent; * add a "Mobile" field in the list views of the "Email sent" smart button: * adapt the TEST button > Test Mailing modal to SMS (we should have 1 button for Email and 1 for SMS); update description; * default value for the Recipients field should be Name of the current user, work mobile/phone number; * If there are no Work Mobile/Phone numbers set on res.users, display (123)-456-7890 instead; * rename the Send Sample Mail button into Send Sample SMS; * adapt the SEND NOW button > Confirmation modal to SMS. Change the message into "This will send the SMS Text Message to all recipients. Do you still want to proceed?" * hide the following elements: Subject, From, Reply to, Attachments, Mail Server, Mail Body tab; Opened, Replied; * adapt the label of the following "warnings" to SMS * x SMS Text Message(s) have been ignored and will not be sent. * x SMS Text Message(s) are in queue and will be sent soon. * x SMS Text Message(s) could not be sent. Mailing kanban view * hide the following stats: https://nimb.ws/grvBn0: Opened, Replied; Mailing list / contact management * following fields should be left empty: https://nimb.ws/3HBeJL: Opened, Replied; * when browsing through mailing lsits and contacts through the Mass SMS application, update actions and views to hide fields related to email and display only phone-related information; UTM Campaign * form view > Related Mailings tab: the following fields should be left empty if notification type = SMS: https://nimb.ws/nfvr1O: Opened, Replied Mass Mailing > Reporting (mail.trace.report model) * adapt the reporting based on the fact that we do not have the following metrics for SMS: Opened, Replied; Mass Mailing > Configuration > Blacklist * do not display any email information (phone blacklist is about phone); * support phone blacklist. Phone blacklist is therefore a separate model from mail.blacklist to simplify management. It is included in sms sending process like mail blacklist when mailing in mass; Opt-out and blacklist handling * we do support mailing lists because they could come from different sources and are a way to communicate with a specific audience (and not just a list we bought), e.g. subscribe to this list to be kept updated whenever this product is back in stock, or to receive results of this ... * if the SMSing is from a list, opt-out removes ourselves from the list; * if it is from the contact ==> Sent to blacklist; * allow to attach unsubscription links in sent SMS, redirecting to a new route in mass mailing SMS allowing quick unsubscribe and/or blacklist of phone numbers; Error management * if the user clicks on Send Now / Schedule / Test and does not have enough credits, open the "Insufficient credits" modal in a lazy option (aka when having failed statistics linked to insufficient credits); * on the mailing, we however display this failure as : * a message on the mailing kanban view * a message on the top of the form view + same behavior as the mailing and "Could not be sent" https://www.screencast.com/t/BExgd1Gc; LINKS Task 1997464 PR #34424 Original SMS addition: Task 1922163 (4287481)
2019-08-12[IMP] phone_validation: add blacklist mechanismThibault Delavallée
PURPOSE SMS are a powerful marketing tool. For instance it is perfect to announce a sale or to communicate a coupon code, to welcome a new customer in a fidelity program, ... Purpose of this task is to integrate SMS sending in batch in mass mailing. It will use same mailing objects but sending SMS instead of emails. Some metrics and flows will have to be slightly updated at the same time. SPECIFICATIONS Purpose of this commit is to add a blacklist mechanism for phone numbers used to send SMS like what already exists for email addresses when sending emails. Define a new phone.blacklist model, holding a number and the state of the blacklist (active field), as well as tools methods to access it. Make it as private as possible, accessing it in sudo once access are granted. Also clean phone validation tools: lessen number of tool functions and update caller to simplify code readability. Some fixes are also included in this commit, notably blank spaces cleaning in phone numbers. Improve phone.validation.mixin to add a tool method computing a sanitized number, in addition to formatting it to national / international. Define a new mail.thread.phone mixin computing the blacklist status of a record. This mixin * inherit from phone.validation.mixin in order to have access to some base phone number parsing capabilities; * computes a sanitized phone number based on ´´_phone_get_number_fields´´. It takes first sanitized value, trying each field returned by the method. That means one sanitized phone number is available per record even if several fields are available; * compute blacklist state of records. It is based on phone.blacklist model and give an easy-to-use field and API to manipulate blacklisted records; * give some API methods : * ``_phone_set_blacklisted``: set recordset as blacklisted; * ``_phone_reset_blacklisted``: reactivate recordset (even if not blacklisted this method can be called safely); Put menus in technical in order to have access to it. Add a Phone / SMS menu below "Email" and use it to store SMS / Phone actions. Finally prepare tests addition by performing some light cleaning while adding blacklist tests. Purpose is to ease future tests related to SMS. LINKS Task 1997464 PR #34424 Original SMS addition: Task 1922163 (4287481)
2019-07-18[IMP] sms: improve composer behaviorThibault Delavallée
PURPOSE Purpose of this commit is to add options and improve sms composer behavior. Followup of merge 4287481bf03fbb6539313ff657af0ca58e2895e7 . SPECIFICATIONS * mass mode: add an option to keep archives when doing mass sms. This mode is actually a _message_sms in batch using the note subtype to speedup the process; * improve _message_sms_schedule_mass to allow more fine-tuning of options when calling it; * do not block sending SMS in batch if some recipients are invalid. Indeed using notifications there will be traces of failed SMS; * avoid reload of form view; Linked to task 1925950 and 1935280 Part of PR #34864
2019-07-12[REF] sms: refactor message_post using SMS notificationsThibault Delavallée
Purpose of this commit is to better include SMS notifications when posting a message. SMS is now just another way of notifying people along with Inbox and email. Following recent mail merge improving notification mechanism [1] we have to define a _notify_record_by_sms method on mail.thread. When a message_post is done using message_type being ``sms`` notification type of customers is set to sms. Customers can be computed on model (generally based on partner_id field) or directly set usign partner°ids. Notification model is updated to store this information directly inside the notification itself. An new ``_message_sms`` helper method is introduced in SMS module allowing to send messages using sms type and notification with a reduced parameters number. It is just a shortcut to message_post, easier to use. Either it computes default recipients on the record set, either it is based on given partners and numbers to notify. The following use cases are notably supported * default computation: find customer, notify by sms; * force recipients to notify by sms (partner_ids); * give a set of numbers to notify by sms (sms_nubmers), not necessarily linked to existing partners; * force number / customer relationship independently of mobile number defined on customer (for example when sending an SMS directly from a mobile field on a lead linked to a customer); Tests are updated accordingly. Performance tests are added in order to have some insights on queries generated when sending SMS, like already done for mail.thread alone. Related to task 1922163 Linked to PR #33510 [1] see be2795513644f09f6b443f462bb67cc5a0762e8d: performance and notification code improvements Co-Authored-By: Thibault Delavallee <tde@odoo.com> Co-Authored-By: Pierre Rousseau <pro@odoo.com>
2019-07-02[ADD] sms, test_mail(_full): add basic SMS tests and improve test toolsThibault Delavallée
Purpose of this commit is to improve and add tools, methods and data to test mail and SMS features. We also add tests for current implementation of SMS feature, allowing to better understand future changes. [ADD] test_mail_full * have a module depending on mail sub-applications like sms or snailmail. Its purpose is to check that standard mail features work effectively with all overrides and extra behaviors activated; * add a new model specific for SMS gateway, with default recipient computation; * add SMS tests for SMS module adding SMS capabilities linked to mail feature. This commit tests SMS feature before the upcoming refactoring and improvement of SMS module in community: posting with SMS and sms composer usage; In test_mail * add necessary mobile information on test partners; * improve assertBusNotification that was not correctly asserting all items in message of bus notifications; In sms * add mock for SMS sending. Purpose is to mock the connection to IAP services by mocking the call to IAP server. It allows to perform SMS tests without having to contact (and pay) for this service; * allow some customization when calling the SMS gateway mock to simulate errors and test corner cases; Related to task 1922163 Linked to PR #34516