# Path: authemail/models.py
# class SignupCode(AbstractBaseCode):
#     ipaddr = models.GenericIPAddressField(_('ip address'))
# 
#     objects = SignupCodeManager()
# 
#     def send_signup_email(self):
#         prefix = 'signup_email'
#         self.send_email(prefix)
# 
# class PasswordResetCode(AbstractBaseCode):
#     objects = PasswordResetCodeManager()
# 
#     def send_password_reset_email(self):
#         prefix = 'password_reset_email'
#         self.send_email(prefix)
# 
# Path: authemail/models.py
# class EmailChangeCode(AbstractBaseCode):
#     email = models.EmailField(_('email address'), max_length=255)
# 
#     objects = EmailChangeCodeManager()
# 
#     def send_email_change_emails(self):
#         prefix = 'email_change_notify_previous_email'
#         self.send_email(prefix)
# 
#         prefix = 'email_change_confirm_new_email'
#         ctxt = {
#             'email': self.email,
#             'code': self.code
#         }
# 
#         send_multi_format_email(prefix, ctxt, target_email=self.email)


import re
from datetime import timedelta
from django.core import mail
from django.contrib.auth import get_user_model
from django.test.utils import override_settings
from django.urls import reverse
from rest_framework import status
from rest_framework.authtoken.models import Token
from rest_framework.test import APITestCase
from authemail.models import SignupCode, PasswordResetCode
from authemail.models import EmailChangeCode
        }
        response = self.client.get(url, params)

        # Send Password Reset Verified request
        url = reverse('authemail-password-reset-verified')
        params = {
            'code': 'XXX',
            'password': self.user_verified_pw_reset,
        }
        response = self.client.post(url, params)

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(response.data['detail'], 'Unable to verify user.')

    def test_password_reset_verified_user_verified(self):
        # Send Password Reset request for not used code
        url = reverse('authemail-password-reset')
        payload = {
            'email': self.user_verified_email,
        }
        response = self.client.post(url, payload)
        password_reset_code = PasswordResetCode.objects.latest('code')
        code_not_used = password_reset_code.code

        # Send Password Reset request for used code
        url = reverse('authemail-password-reset')
        payload = {
            'email': self.user_verified_email,
        }
        self.client.post(url, payload)

# Path: authemail/models.py
# class SignupCode(AbstractBaseCode):
#     ipaddr = models.GenericIPAddressField(_('ip address'))
# 
#     objects = SignupCodeManager()
# 
#     def send_signup_email(self):
#         prefix = 'signup_email'
#         self.send_email(prefix)
# 
# class PasswordResetCode(AbstractBaseCode):
#     objects = PasswordResetCodeManager()
# 
#     def send_password_reset_email(self):
#         prefix = 'password_reset_email'
#         self.send_email(prefix)
# 
# Path: authemail/models.py
# class EmailChangeCode(AbstractBaseCode):
#     email = models.EmailField(_('email address'), max_length=255)
# 
#     objects = EmailChangeCodeManager()
# 
#     def send_email_change_emails(self):
#         prefix = 'email_change_notify_previous_email'
#         self.send_email(prefix)
# 
#         prefix = 'email_change_confirm_new_email'
#         ctxt = {
#             'email': self.email,
#             'code': self.code
#         }
# 
#         send_multi_format_email(prefix, ctxt, target_email=self.email)


# Path: authemail/tests.py
import re
from datetime import timedelta
from django.core import mail
from django.contrib.auth import get_user_model
from django.test.utils import override_settings
from django.urls import reverse
from rest_framework import status
from rest_framework.authtoken.models import Token
from rest_framework.test import APITestCase
from authemail.models import SignupCode, PasswordResetCode
from authemail.models import EmailChangeCode

        }
        response = self.client.get(url, params)

        # Send Password Reset Verified request
        url = reverse('authemail-password-reset-verified')
        params = {
            'code': 'XXX',
            'password': self.user_verified_pw_reset,
        }
        response = self.client.post(url, params)

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(response.data['detail'], 'Unable to verify user.')

    def test_password_reset_verified_user_verified(self):
        # Send Password Reset request for not used code
        url = reverse('authemail-password-reset')
        payload = {
            'email': self.user_verified_email,
        }
        response = self.client.post(url, payload)
        password_reset_code = PasswordResetCode.objects.latest('code')
        code_not_used = password_reset_code.code

        # Send Password Reset request for used code
        url = reverse('authemail-password-reset')
        payload = {
            'email': self.user_verified_email,
        }
        self.client.post(url, payload)

        password_reset_code = PasswordResetCode.objects.latest('code')