Commit Graph
429 Commits
Author SHA1 Message Date
Thibault Delavallée de6e980f59 [IMP] mail: slightly improve tool to call mail gateway in tests
We now also support formatting a return path when emulating incoming emails.
Purpose is to integrate some more tests in a near future about incoming
emails, notably in CRM.

This commit is a preliminary cleaning coming from task 2088565 about CRM
onchange to compute methods update.

LINKS

Task ID 2088565
Community PR #42344
Enterprise PR odoo/enterprise#7403
2019-12-24 13:14:02 +00:00
Thibault Delavallée c3be4c3bc6 [IMP][MOV] mail: move / pimp test tools and asserts to mail
PURPOSE

Currently tools and asserts for mail tests are located inside test_mail
module. It makes difficult to re-use them in application tests or force them
to write custom quick and dirty tools and asserts. Purpose of this merge
is therefore to move tools classes and mocks to mail directly and use them
in various sub modules.

SPECIFICATIONS

Have class, mocks, tools and asserts available in mail so that all modules
below from mail can use them.

Including

  * mock mail gateway in a clean way: mock server connection, email building
    and sending;
  * allow to simulate errors while sending emails to test corner cases;
  * provide tools to insert emails in mail gateway;
  * mock mail application to check record creation (message, notifications,
    mails, ...);
  * mock bus notification;
  * provide clearer assert methods for bus and mail notifications;
  * provide clearer emails sending and content methods;
  * provide a with_user tool context manager for tests allowing to quickly
    change current user given a login;

Most of those tools, asserts and mocks come from test_mail/tests/common.py.
They have been partially rewritten to be easier to use or to perform tests
more cleanly.

Future commits will gradually update existing tests in test_mail, test_mass
mailing and test_mail_full.

LINKS

Task ID 2068986
PR #38070
2019-11-20 16:00:32 +00:00
Thibault Delavallée d040bfde89 [MOV] (test_)mail: move tests into their dedicated module
Purpose: avoid having useless tables for test models in a
production environment.
2017-11-29 10:11:15 +01:00
Thibault Delavallée 7a136d6acc [REM] mail: tests: remove unnecessary common data 2017-11-29 10:11:14 +01:00
Thibault Delavallée 32c08fd73c [IMP] mail: tests: add activity tests 2017-11-29 10:11:14 +01:00
Thibault Delavallée 2b6d840822 [IMP] mail: tests: clean test mail template 2017-11-29 10:11:14 +01:00
Thibault Delavallée ac9103adbd [IMP] mail: tests: clean mail gateway tests
Purpose is to lessen noise and make tests less low-level. Including :

 * use of new models and data;
 * lessen low level tests;
 * some light cleaning;
2017-11-29 10:11:13 +01:00
Thibault Delavallée 53d65ed71a [IMP] mail: tests: clean and improve mail tracking tests
Purpose is to lessen noise and make tests less low-level. Including :

 * clean and remove most of old tests, low-level and not very useful;
 * add tests for several cases, like simple tracking, tracking linked to
   a mail.message.subtype, trackink automatically sending emails based
   on some template;
2017-11-29 10:11:09 +01:00
Thibault Delavallée 99ee2f344a [IMP] mail: tests: clean and improve mail followers tests
Purpose is to lessen noise and make tests less low-level. Including :

 * add test for the various auto subscription cases, notably through
   umbrella (like project -> task auto subscription);
 * remove low-level tests; there is no need to test the output of add
   followers method as it is only an implementation details;
2017-11-29 10:05:01 +01:00
Thibault Delavallée f8118d8c8b [IMP] mail: tests: clean mail message tests
Purpose is to lessen noise and make tests less low-level. Including :

 * move mail_mail model specific tests to its own file;
 * move feature specific tests to its own file;
 * add missing loggers to lessen noise;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 846352f00d [IMP] mail: tests: clean and improve mail channel tests
Purpose is to lessen noise and make tests less low-level. Including :

 * tests should be more about channel listeners than followers as
   channels should not have followers;
 * test email_send that trigger the mailing list behavior;
 * currently add some join and leave channel methods are those are
   missing in the base model:
 * test joining and leaving channels that should not change
   followers but members;
 * use less preconfigured data;
 * add some mute loggers to lessen noise;
 * remove some old code about patching that is not necessary anymore and
   could actually create funny bugs;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 9150443465 [IMP] mail: tests: clean server actions tests
Purpose is to lessen noise and make tests less low-level. Including :

 * remove unnecessary fail string;
 * remove unnecessary method return value test as this is low level;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 15e131907f [IMP] mail: tests: clean invite wizard tests
Purpose is to lessen noise and make tests less low-level. Including :

 * remove test of emails content as this is too low-level and not really
   interesting. Purpose of test is to check followers have been added
   and not the content of a template;
 * remove unnecessary fail string;
 * remove unnecessary low level checks;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 12fd198bcf [IMP] mail: tests: clean test discuss and test message compose
Purpose is to be less low level and improve code coverage by adding
tests if required. Duplicated or redundant tests are removed to lessen
number of tests. Notably content of notification emails, recipients and
specific chatter control through context keys are more tested.

Some more tests about buttons present in notifications emails should be
added. Maybe in a near future. I hope so.
2017-11-29 10:05:01 +01:00
Thibault Delavallée 50aaaa69be [REM] mail: tests: remove test message read
This is some remains of old message_read / message_fetch tests linked to
the old chatter using threaded display. Tests have been removed when the
feature was changed. Only the setup was left. Let us get rid of it.
2017-11-29 10:05:01 +01:00
Thibault Delavallée de25767ffc [IMP] mail: tests: improve / add common classes and data for mail tests
This commit improves common classes and add helpers for mail tests.
Future commits will use this new stuff to improve the tests.

 * improve existing models and add some of them. There are now several
   models

  * mail.test.simple: chatter-enabled record without any really advanced
    feature. Can be used everywhere standard chatter and communication
    tests are required;
  * mail.test.track: chatter-enabled record with basic value tracking
    and responsible tracking;
  * mail.test.activity: chatter-enabled record using activities;
  * mail.test.full: complete chatter-enabled record with advanced
    tracking, automatic subscription and automatic email send based on
    templates and tracking;
  * mail.test: chatter-enabled record having an alias. It can be used
    where umbrella record like projects or teams has to be used in
    tests;

 * add MockEmails test class: this class mocks the mail gateway so that
   tests can work on emails without actually sending them. It is taken
   out of TestMail class to clearly separate features from class;
 * improve created data in the various classes and prepare work to
   lessen created data during tests;
 * add helpers on base test class, notably

  * sudoAs: context manager to run a code snippet using a given user;
  * assertNotifications: assert notification content, aka Inbox or email
    notification and their content; may be subject to change depending on
    mail evolution;
  * assertEmails: check content of sent emails;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 2a3ac4ce22 [MOV] mail: reorganize content of tests, separate tests from models and data
Purpose of this commit is to reorganize the mail tests. Containing

 * move test models into mail/tests/models/;
 * move data into mail/tests/data even if it is python code, as it is
   likely that some additional data will appear soon;
 * split test_mail_features into test for discuss app and test related
   to message post and composer, to better identify test target;
 * split and remove test_portal, those tests are now integrated in the
   other tests;

There is no change in this commit. Only some renaming and file move or
split.

mergeup: remove / split test portal
2017-11-29 10:05:01 +01:00
Thibault Delavallée 1fbc29a641 [MOV] base: move ir_* models into models/ 2017-11-27 11:15:03 +01:00
Christophe Simonis a094f6318b [MERGE] forward port branch saas-16 up to 745d00362a 2017-11-16 12:40:36 +01:00
Christophe Simonis 5877b7b38c [MERGE] forward port branch saas-15 up to 73e4dacf78 2017-11-15 15:50:36 +01:00
Christophe Simonis 73e4dacf78 [MERGE] forward port branch saas-14 up to 0bf7ab4511 2017-11-15 15:20:52 +01:00
Christophe Simonis 0d0dd0c866 [MERGE] forward port branch 10.0 up to a8b72d764e 2017-11-14 11:27:04 +01:00
Christophe Simonis a8b72d764e [MERGE] forward port branch 9.0 up to d07f9c5ef5 2017-11-14 11:26:02 +01:00
Manuel Vázquez Acosta d6c2906d44 [FIX] mail: access the super of TestMailGroup
Instead of the parent of TestMail class

Closes #20728
2017-11-13 16:41:03 +01:00
Raphael Collet 36141931bf [FIX] mail: remove field res_model_id for performance reasons (#19744) 2017-09-27 16:58:19 +02:00
Thibault Delavallée 0296f198b2 [IMP] mail: tests: add a new simple base model for testing
Purpose: have simple test models to use in various modules and be
independent from standard models behavior / tweaking.
2017-09-15 15:56:23 +02:00
Raphael Collet 55549f1e61 [ADD] base: direct support for binding an action to a model 2017-08-28 09:53:23 +02:00
Christophe Simonis 017ee5eab3 [MERGE] forward port branch saas-17 up to 877e709871 2017-08-24 13:17:53 +02:00
Xavier Morel 200612ca1e [FIX] P3: text model in various mail bits
No formal decision there, and the stdlib API seems like a PITA as it's
based around native strings, not bytes and not text.

* try to use cross-model API instead of random encode/decode
* unicode all the mail_template things
* formataddr *requires* a text tuple now

  In P2, formataddr((False, False)) "worked" (generated "False
  <False>"), in P3 it will fail and blow up.
* attachments are quite definitely bytes
* remove try_coerce_ascii because it's garbage
2017-08-20 23:25:54 +02:00
Xavier Morel 3824b5dcc1 [FIX] P3: fix base64 and StringIO uses
* StringIO removed from stdlib, replace with io
* try to correctly handle BytesIO/StringIO (one is for bytes the other
  is for text)
* fix base64: Python 3 removed bytes-encoding and bytes-bytes
  codecs (via #encode) so replace all calls to str.encode('base64'),
  also b64encode is a bytes->bytes conversion so attempt to properly
  handle that

issue #8530
2017-08-20 23:25:54 +02:00
Thibault Delavallée ee4cf1eae3 [MOV] website_portal: move mail portal tests directly to mail
Those belong to mail, not website_portal.
2017-08-08 15:05:11 +02:00
Christophe Simonis 4f501348c4 [MERGE] forward port branch saas-16 up to 46e1104ce1 2017-07-26 19:55:44 +02:00
Christophe Simonis 46e1104ce1 [MERGE] forward port branch saas-15 up to 681f03e309 2017-07-26 19:41:57 +02:00
Christophe Simonis 681f03e309 [MERGE] forward port branch saas-14 up to c4e9b854ff 2017-07-26 18:47:54 +02:00
Christophe Simonis c4e9b854ff [IMP] core: log bad queries as ERROR
Also adapt default config and config mapping.
2017-07-26 17:46:20 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Aline Preillon 2950ffaa86 [IMP] mail: improve notification management, either email either inbox
Currently partners have a boolean field to choose whether to receive
notifications only in their Odoo inbox or to receive them in their inbox
and by email. This leads to several issues :

 * if a customer is configured to not receive emails he will not receive
   any notification on sales orders, leads, ... This is not clearly
   indicated to the salesman and it is not easy to know how to change
   that behavior
 * if an user chooses to receive emails and does not use its inbox a lot
   of notifications stay in Odoo. The user has to manually set them as
   done to make them disappear which is redundant.

This commit changes that behavior. From now on customers will always
receive all notifications by email. Indeed Odoo is not a customer oriented
mailbox. Moreover sales orders or discussions on leads send to customers
should always be sent by email as it is the standard communication
mechanism. Users will be able to choose to receive notifications in Odoo
or by email. The choice is no longer inbox or inbox + email, but inbox
or email. Choosing one option or the other one depends on the way the
user wants to work.

Technically the field is moved on the users model and selection keys
are renamed. Notification process is modified

 * notified_partner_ids contains as before specified recipients as well
   as followers matching the subtype
 * customers and users working with emails are notified. During that
   process customers notifications are marked as done to be able to
   track the email state without having needaction. Users notifications
   are currently deleted as we do not track their email state.

The removal of partner field implies changes in various addons that
define partner data with this field set in the values.
2017-02-21 16:42:11 +01:00
Thibault Delavallée eb3a531666 [IMP] mail: small code linting in notification methods
This commit cleans code to separate recipients computation in mail
message from notification mechanism in partner. There is no functional
change. Some variables have been renamed notably to know that
some of the record sets are sudoed during computation.
2017-02-21 16:41:15 +01:00
Thibault Delavallée 927fbe8845 [IMP] mail: make tests less dependent on mail.channel model
Currently almost all mail tests run on mail.channel model. Indeed it is
the only model inheriting from mail.thread and mail.alias when having only
mail installed. However channel model have several specific features and
is not totally a standard mail.thread model. For example notification
recipients are computed a bit differently.

Since 4f9105a4ef mail module has a test
model allowing to perform tests on a very simple mail.thread-like model.
This commit make mail tests use this test model instead of mail.channel
everywhere it is possible. Channel model should be used only when tests
are channel-dependent.
2017-02-21 16:41:14 +01:00
Thibault Delavallée 80d26e26bb [IMP] mail: notify author of internal notes when replied through gateway
Currently if an user mentions someone in an internal note he is not
notified of any reply as replies create internal notes. This commit
ensure the author of the first note is notified of the reply even
if it is still an internal note.

Tests have been updated accordingly.
2017-02-21 10:39:43 +01:00
Thibault Delavallée 1d9052fc19 [IMP] mail: add tests about replies to internal note through mailgateway
Replying to internal notes should create internal notes and should
not notify anyone. Future commit will change that behavior. This
commit ensure the current behavior is working as intended.
2017-02-21 10:39:43 +01:00
Christophe Simonis 6c4389df41 [MERGE] forward port branch 10.0 up to 6804085b8c 2017-01-23 14:33:53 +01:00
Christophe Simonis 44276dfdc3 [MERGE] forward port branch saas-11 up to a0aca47fef 2017-01-17 19:12:20 +01:00
Christophe Simonis 70f86ce4e8 [MERGE] forward port branch 9.0 up to 16fa61b34f 2017-01-17 18:04:57 +01:00
Christophe Simonis 16fa61b34f [MERGE] forward port branch saas-6 up to 7cb977fc3c 2017-01-17 16:11:05 +01:00
Christophe Simonis ecd03bec8a [MERGE] forward port branch 8.0 up to 8f1c2bfc91 2017-01-17 14:17:56 +01:00
Christophe Simonis 8f1c2bfc91 [FIX] mail: force mail.message linked record invalidation 2017-01-17 14:14:16 +01:00
Christophe Simonis 4d619c221f [MERGE] forward port branch 8.0 up to 082495240f 2017-01-16 12:30:53 +01:00
Raphael Collet a1be7ca551 [FIX] mail, purchase: avoid full cache invalidation when possible (#14934)
* [FIX] mail: avoid full cache invalidation when possible

* [FIX] purchase: avoid full cache invalidation when possible
2017-01-12 11:31:58 +01:00