mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-26 02:53:51 +02:00
Renamed main script and added test script (to separate concerns of testing vs combining transition domain migration scripts). Added test data files.
This commit is contained in:
parent
d5e9e45a2f
commit
02ec4d7bae
5 changed files with 607 additions and 0 deletions
|
@ -0,0 +1,42 @@
|
|||
from django.test import TestCase
|
||||
from django.db.utils import IntegrityError
|
||||
from unittest.mock import patch
|
||||
|
||||
from registrar.models import (
|
||||
Contact,
|
||||
DomainApplication,
|
||||
DomainInformation,
|
||||
User,
|
||||
Website,
|
||||
Domain,
|
||||
DraftDomain,
|
||||
DomainInvitation,
|
||||
UserDomainRole,
|
||||
)
|
||||
|
||||
import boto3_mocking # type: ignore
|
||||
from .common import MockSESClient, less_console_noise, completed_application
|
||||
from django_fsm import TransitionNotAllowed
|
||||
|
||||
boto3_mocking.clients.register_handler("sesv2", MockSESClient)
|
||||
|
||||
@boto3_mocking.patching
|
||||
class TestInvitations(TestCase):
|
||||
|
||||
"""Test the retrieval of invitations."""
|
||||
|
||||
def setUp(self):
|
||||
self.domain, _ = Domain.objects.get_or_create(name="igorville.gov")
|
||||
self.email = "mayor@igorville.gov"
|
||||
self.invitation, _ = DomainInvitation.objects.get_or_create(
|
||||
email=self.email, domain=self.domain
|
||||
)
|
||||
self.user, _ = User.objects.get_or_create(email=self.email)
|
||||
|
||||
# clean out the roles each time
|
||||
UserDomainRole.objects.all().delete()
|
||||
|
||||
def test_user_logins(self):
|
||||
"""A new user's first_login callback retrieves their invitations."""
|
||||
self.user.first_login()
|
||||
self.assertTrue(UserDomainRole.objects.get(user=self.user, domain=self.domain))
|
Loading…
Add table
Add a link
Reference in a new issue