mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-13 14:35:14 +02:00
Send domain invitations to particular email addresses, tests don't work
This commit is contained in:
parent
3eef418ff8
commit
ab35221724
2 changed files with 39 additions and 4 deletions
|
@ -37,14 +37,28 @@ class Command(BaseCommand):
|
|||
help="Send emails ",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"emails",
|
||||
nargs="*",
|
||||
help="Email addresses to send invitations to"
|
||||
)
|
||||
|
||||
def handle(self, **options):
|
||||
"""Process the objects in TransitionDomain."""
|
||||
|
||||
logger.info("checking domains and preparing emails")
|
||||
# Get all TransitionDomain objects
|
||||
self.transition_domains = TransitionDomain.objects.filter(
|
||||
email_sent=False,
|
||||
).order_by("username")
|
||||
|
||||
if options["emails"]:
|
||||
# this option is a list of email addresses
|
||||
self.transition_domains = TransitionDomain.objects.filter(
|
||||
username__in=options["emails"],
|
||||
email_sent=False,
|
||||
).order_by("username")
|
||||
else:
|
||||
# Get all TransitionDomain objects
|
||||
self.transition_domains = TransitionDomain.objects.filter(
|
||||
email_sent=False,
|
||||
).order_by("username")
|
||||
logger.info("Found %d transition domains", len(self.transition_domains))
|
||||
|
||||
self.build_emails_to_send_array()
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from io import StringIO
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from registrar.models import (
|
||||
|
@ -11,6 +13,8 @@ from registrar.models import (
|
|||
|
||||
from django.core.management import call_command
|
||||
|
||||
from .common import less_console_noise
|
||||
|
||||
|
||||
class TestLogins(TestCase):
|
||||
|
||||
|
@ -259,3 +263,20 @@ class TestLogins(TestCase):
|
|||
expected_missing_domain_informations,
|
||||
expected_missing_domain_invitations,
|
||||
)
|
||||
|
||||
def test_send_domain_invitations_email(self):
|
||||
"""Can send only a single domain invitation email."""
|
||||
with less_console_noise():
|
||||
self.run_load_domains()
|
||||
self.run_transfer_domains()
|
||||
|
||||
# this is one of the email addresses in data/test_contacts.txt
|
||||
output_stream = StringIO()
|
||||
call_command("send_domain_invitations",
|
||||
stdout=output_stream)
|
||||
|
||||
# Check that we had the right numbers in our output
|
||||
output = output_stream.getvalue()
|
||||
print("Output:", output)
|
||||
self.assertIn("Found 1 transition domains", output)
|
||||
self.assertTrue("would send email to testuser@gmail.com", output)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue