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

✨(dimail) send pending mailboxes upon domain activation #635

Merged
merged 3 commits into from
Feb 3, 2025

Conversation

mjeammet
Copy link
Contributor

@mjeammet mjeammet commented Jan 10, 2025

Purpose

send creation requests to dimail for all pending mailboxes
when domain goes from "pending" to "enabled".

Proposal

Description...

  • when domain is first activated, all pending mailboxes are sent to dimail for actual creation
  • relevant tests
  • added a few dimail responses to fixture module, to simulate dimail's reponses easily and "factorize" code

For next PR

  • what happens when a supposedly "pending" email already exists in dimail (or we have a homonym situation).

@mjeammet mjeammet self-assigned this Jan 10, 2025
@mjeammet mjeammet force-pushed the mpj/dimail/enable-pending-mailboxes branch 3 times, most recently from f83a1f2 to 4e40e96 Compare January 15, 2025 16:50
@mjeammet mjeammet marked this pull request as ready for review January 15, 2025 16:51
@mjeammet mjeammet force-pushed the mpj/dimail/enable-pending-mailboxes branch 2 times, most recently from 470a3c2 to 3bc4024 Compare January 29, 2025 14:27
@mjeammet mjeammet requested a review from sdemagny January 30, 2025 10:16
@mjeammet mjeammet force-pushed the mpj/dimail/enable-pending-mailboxes branch 2 times, most recently from 04ea13d to f0edee4 Compare January 31, 2025 17:47
@mjeammet mjeammet enabled auto-merge (rebase) January 31, 2025 17:52
Copy link
Contributor

@sdemagny sdemagny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya quelques pétouilles dans les tests à corriger. Rien de bien méchant.

@@ -23,6 +23,28 @@
)


@pytest.mark.django_db
def test_admin_action__should_not_sync_if_domain_enabled(client):
"""Test admin action to check health of some domains"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

la docstring n'est pas bonne

@@ -13,9 +13,15 @@
@admin.action(description=_("Synchronise from dimail"))
def sync_mailboxes_from_dimail(modeladmin, request, queryset): # pylint: disable=unused-argument
"""Admin action to synchronize existing mailboxes from dimail to our database."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peut-être rajouter qu'uniquement les boites mail des domaines enabled sont synchronisables.



@pytest.mark.django_db
def test_admin_action__fetch_domain_status_from_dimail(client):
def test_admin_action__should_not_sync_if_domain_enabled(client):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est l'inverse c'est pour les domains not enabled.
Mais est-ce que ça ne serait pas encore mieux d'avoir à la place de _admin_action__ qui est déjà dans le nom du module, l'action en question ? Ça serait plus facile de savoir tout de suite quelle action de l'admin on teste.

Suggested change
def test_admin_action__should_not_sync_if_domain_enabled(client):
def test_sync_mailboxes__should_not_sync_if_domain_is_not_enabled(client):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absolument ! ouhla ça commence à sentir la fatigue, cette PR ^

src/backend/mailbox_manager/tests/test_admin_actions.py Outdated Show resolved Hide resolved
src/backend/mailbox_manager/tests/test_admin_actions.py Outdated Show resolved Hide resolved
src/backend/mailbox_manager/tests/test_admin_actions.py Outdated Show resolved Hide resolved
src/backend/mailbox_manager/tests/test_admin_actions.py Outdated Show resolved Hide resolved
@mjeammet mjeammet force-pushed the mpj/dimail/enable-pending-mailboxes branch from f0edee4 to c1dc4ea Compare February 3, 2025 10:48
def test_sync_mailboxes__should_not_sync_if_domain_is_not_enabled(
domain_status, client
):
"""Mailboxes should not be sync'ed on non-enabled domaisn"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Mailboxes should not be sync'ed on non-enabled domaisn"""
"""Mailboxes should not be sync'ed on non-enabled domains"""

@sdemagny sdemagny disabled auto-merge February 3, 2025 11:19
Copy link
Contributor

@sdemagny sdemagny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il y a juste une petite typo à corriger.
Je te le tamponne.

@mjeammet mjeammet force-pushed the mpj/dimail/enable-pending-mailboxes branch 2 times, most recently from b6eae39 to 01fa7b9 Compare February 3, 2025 12:32
send creation requests to dimail for all pending mailboxes
when domain goes from "pending" to "enabled".
dimail's ok response upon mailbox creation is used in several tests.
All those tests now reference proper response available in fixtures.
Pending, failed and deactivated domains should not be sync'ed.
@mjeammet mjeammet force-pushed the mpj/dimail/enable-pending-mailboxes branch from 01fa7b9 to c5f8cc3 Compare February 3, 2025 12:35
@mjeammet mjeammet merged commit 7f0e231 into main Feb 3, 2025
19 checks passed
@mjeammet mjeammet deleted the mpj/dimail/enable-pending-mailboxes branch February 3, 2025 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants