From 85d4f959b201687377d3abdda3b23c2909af001e Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Mon, 6 May 2024 10:55:59 +1000 Subject: [PATCH] Confirm command does not send duplicates --- .../commands/test_sendapimoveannouncement.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api/test/unit/management/commands/test_sendapimoveannouncement.py b/api/test/unit/management/commands/test_sendapimoveannouncement.py index 360aeeb9f6d..63f027990e7 100644 --- a/api/test/unit/management/commands/test_sendapimoveannouncement.py +++ b/api/test/unit/management/commands/test_sendapimoveannouncement.py @@ -85,3 +85,18 @@ def test_should_not_send_to_unverified_emails(captured_emails): call_cmd(dry_run=False) assert len(captured_emails) == 0 + + +@pytest.mark.django_db +def test_should_not_send_to_email_twice(captured_emails): + emails = make_emails(10, verified=True) + OAuth2VerificationFactory.create( + email=emails[0], + ) + + call_cmd(dry_run=False) + # Not 11 + assert len(captured_emails) == 10 + + # Only appears once + assert len([email for email in emails if email == emails[0]]) == 1