Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MERGE] {test_}mail{_full / mass_mailing}: move helper tools and classes from test_mail to mail to ease reuse #38070

Closed

Conversation

@tde-banana-odoo
Copy link
Contributor

tde-banana-odoo commented Oct 7, 2019

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.

In this merge we gradually apply changes on existing tests in test_mail,
test_mass_mailing and test_mail_full. First commits will provide the new
classes, then tests will be updated, and finally dead classes removed.
Having it done step by step make it easier to read and understand.

LINKS

Task ID 2068986
PR #38070

@robodoo robodoo added the seen 🙂 label Oct 7, 2019
@C3POdoo C3POdoo added the RD label Oct 7, 2019
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-mail-tests-tools-tde branch 4 times, most recently from 69f8fd5 to 994f4d2 Oct 8, 2019
failed.sudo().write({
'notification_status': 'exception',
'failure_type': failure_type,
'failure_reason': failure_reason,
})
messages = notifications.mapped('mail_message_id').filtered(lambda m: m.is_thread_message())
print('Notifying in post process sent message for %s (pids: %s)' % (failed.ids, failed.res_partner_id))

This comment has been minimized.

Copy link
@Xavier-Do

Xavier-Do Oct 10, 2019

Contributor

LGTM for notification fix commit but you forgot a print

@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-mail-tests-tools-tde branch 4 times, most recently from 5c9d92d to eefc033 Oct 11, 2019
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-mail-tests-tools-tde branch from eefc033 to ca879b3 Oct 25, 2019
@KangOl KangOl force-pushed the odoo:master branch from 86c80d3 to ab6d0c3 Nov 6, 2019
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-mail-tests-tools-tde branch 3 times, most recently from 54b73b9 to 921f628 Nov 8, 2019
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-mail-tests-tools-tde branch 3 times, most recently from 4ae9a02 to d222050 Nov 20, 2019
@robodoo robodoo added the CI 🤖 label Nov 20, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 20, 2019
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;
  * 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 odoo#38070
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-mail-tests-tools-tde branch from d222050 to bf2555b Nov 20, 2019
@robodoo robodoo removed the CI 🤖 label Nov 20, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 20, 2019
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 odoo#38070
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 20, 2019
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

In this commit we add ``TestMailCommon`` that will be the class for all test_*
modules linked to mail features. It is build upon tools made available in
mail tests (mocks, tools, asserts) and give the functional basis for mail
tests.

This commit also introduces ``TestMailMultiCompanyCommon`` that is a small
multi company testing class build on ``TestMailCommon``.

``TestRecipients`` class is kept as it creates some testing partners, used
notably for notifications and recipients.

Future commits will gradually make tests use this class instead of the
``BaseFunctionalTest`` that will be set to retirement.

LINKS

Task ID 2068986
PR odoo#38070
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 20, 2019
…to new common

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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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``;

In this commit we update: test_discuss, test_invite, test_ir_actions and
test_odoobot.

LINKS

Task ID 2068986
PR odoo#38070
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 20, 2019
…common

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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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``;

In this commit we update: test_mail_followers, test_mail_mail,
test_mail_template.

LINKS

Task ID 2068986
PR odoo#38070
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 20, 2019
…common

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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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``;

In this commit we update: test_message_composer, test_message_track.

LINKS

Task ID 2068986
PR odoo#38070
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-mail-tests-tools-tde branch from bf2555b to a716283 Nov 20, 2019
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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);
  * remove custom mocks / checks and replace them by now standard mocks
    and assertions (if any);

In this commit we update: test message management

LINKS

Task ID 2068986
PR #38070
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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);

In this commit we update: test message post

LINKS

Task ID 2068986
PR #38070
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 ``MassMailingCase`` and replace it by a fresh
``TestMailCommon`` that is simply updated to hold a marketing user by default.
That way all mocks and asserts are available in all sub test classes.

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
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
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

Now that all tests using old ``BaseFunctionalTest`` and ``MockEmails``
classes are updated we can safely remove them.

LINKS

Task ID 2068986
PR #38070
@tde-banana-odoo tde-banana-odoo force-pushed the odoo-dev:master-mail-tests-tools-tde branch from dd6a821 to 65732cc Nov 20, 2019
@tde-banana-odoo tde-banana-odoo changed the title [MERGE] {test_}mail: move helper tools and classes from test_mail to mail to ease reuse [MERGE] {test_}mail{_full / mass_mailing}: move helper tools and classes from test_mail to mail to ease reuse Nov 20, 2019
@tde-banana-odoo

This comment has been minimized.

Copy link
Contributor Author

tde-banana-odoo commented Nov 20, 2019

@robodoo r+ rebase-merge

@robodoo robodoo added the r+ 👌 label Nov 20, 2019
@robodoo

This comment has been minimized.

Copy link
Contributor

robodoo commented Nov 20, 2019

Merge method set to rebase and merge, using the PR as merge commit message

@robodoo robodoo added the CI 🤖 label Nov 20, 2019
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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

In this commit we add ``TestMailCommon`` that will be the class for all test_*
modules linked to mail features. It is build upon tools made available in
mail tests (mocks, tools, asserts) and give the functional basis for mail
tests.

This commit also introduces ``TestMailMultiCompanyCommon`` that is a small
multi company testing class build on ``TestMailCommon``.

``TestRecipients`` class is kept as it creates some testing partners, used
notably for notifications and recipients.

Future commits will gradually make tests use this class instead of the
``BaseFunctionalTest`` that will be set to retirement.

LINKS

Task ID 2068986
PR #38070
robodoo pushed a commit that referenced this pull request Nov 20, 2019
…to new common

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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);

In this commit we update: test_discuss, test_invite, test_ir_actions and
test_odoobot.

LINKS

Task ID 2068986
PR #38070
robodoo pushed a commit that referenced this pull request Nov 20, 2019
…common

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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);

In this commit we update: test_mail_followers, test_mail_mail,
test_mail_template.

LINKS

Task ID 2068986
PR #38070
robodoo pushed a commit that referenced this pull request Nov 20, 2019
…ity to new common

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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);

In this commit we update: test_message_composer, test_message_track and
test_mail_activity.

LINKS

Task ID 2068986
PR #38070
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);

In this commit we update: test mail channel

LINKS

Task ID 2068986
PR #38070
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);

In this commit we update: test mail gateway

LINKS

Task ID 2068986
PR #38070
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);

In this commit we update: test mail message

LINKS

Task ID 2068986
PR #38070
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);
  * remove custom mocks / checks and replace them by now standard mocks
    and assertions (if any);

In this commit we update: test message management

LINKS

Task ID 2068986
PR #38070
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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 tests to new tools / asserts / helpers / classes defined in mail
and test_mail. 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);

In this commit we update: test message post

LINKS

Task ID 2068986
PR #38070
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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 ``MassMailingCase`` and replace it by a fresh
``TestMailCommon`` that is simply updated to hold a marketing user by default.
That way all mocks and asserts are available in all sub test classes.

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
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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
robodoo pushed a commit that referenced this pull request Nov 20, 2019
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

Now that all tests using old ``BaseFunctionalTest`` and ``MockEmails``
classes are updated we can safely remove them.

LINKS

Task ID 2068986
PR #38070
robodoo added a commit that referenced this pull request Nov 20, 2019
…ses from test_mail to mail to ease reuse

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.

In this merge we gradually apply changes on existing tests in test_mail,
test_mass_mailing and test_mail_full. First commits will provide the new
classes, then tests will be updated, and finally dead classes removed.
Having it done step by step make it easier to read and understand.

LINKS

Task ID 2068986
PR #38070

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
@robodoo

This comment has been minimized.

Copy link
Contributor

robodoo commented Nov 20, 2019

Merged at 169b45d, thanks!

@robodoo robodoo closed this Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.