
    .~h                     F    d dl Z d dlmZ d dlmZ d dlmZ  G d de      Zy)    N)TestCase)forms)	UserModelc                   .    e Zd ZdZd Zd Zd Zd Zd Zy)RegistrationFormTestsz/
    Test the default registration forms.

    c                    t               j                  j                  ddd       d}d}t        j                  dk\  rd}dd	d
d
dd|gfddddddddgfdd
d	d
ddd|gfdg}|D ]e  }t        j                  |d         }| j                  |j                                | j                  |j                  |d   d      |d   d          g t        j                  d
d	d
d
d      }| j                  |j                                y)zo
        Test that ``RegistrationForm`` enforces username constraints
        and matching passwords.

        alicealice@example.comsecretz_Enter a valid username. This value may contain only letters, numbers, and @/./+/-/_ characters.z%The two password fields didn't match.)   r   u'   The two password fields didn’t match.zfoo/barfoo@example.comfoousernameemail	password1	password2r   )dataerror)A user with that username already exists.barr   r   r   r   r      N)r   objectscreate_userdjangoVERSIONr   RegistrationFormassertFalseis_validassertEqualerrors
assertTrue)selfbad_username_errorpassword_didnt_match_errorinvalid_data_dictsinvalid_dictforms         a/var/www/peopleoo.sandbox-dev.co.uk/venv/lib/python3.12/site-packages/registration/tests/forms.pytest_registration_formz,RegistrationFormTests.test_registration_form   sb    	''1DhO1 	 &M">>V#)R& #,0#(#(* "$6#78	: #*2#+#+- "$O#PQ	S #(0#(#(* #%?$@A	C
* / 	7L))|F/CDDT]]_-T[[g)>q)AB)'2157	7 %%5F9>9>,@ A 	(    c                 v   t               j                  j                  ddd       t        j                  ddddd      }| j                  |j                                | j                  |j                  d   d	g       t        j                  ddddd      }| j                  |j                                y
)m
        Test that ``RegistrationFormUniqueEmail`` validates uniqueness
        of email addresses.

        r	   r
   r   Alicer   r   r   r   r   N)
r   r   r   r   !RegistrationFormUsernameLowercaser   r    r!   r"   r#   r$   r)   s     r*   )test_registration_form_username_lowercasez?RegistrationFormTests.test_registration_form_username_lowercase@   s     	''1DhO66FYJOJO=Q R 	)Z0EF	H 66FYJOJO=Q R 	(r,   c                 .   t        j                  ddddd      }| j                  |j                                | j	                  |j
                  d   dg       t        j                  dddddd      }| j                  |j                                y	)
zs
        Test that ``RegistrationFormTermsOfService`` requires
        agreement to the terms of service.

        r   r   r   r   tosz'You must agree to the terms to registeron)r   r   r   r   r4   N)r   RegistrationFormTermsOfServicer   r    r!   r"   r#   r1   s     r*   test_registration_form_tosz0RegistrationFormTests.test_registration_form_tosX   s     33eCTGLGL:N O 	)U+CD	F 33eCTGLGLAE	:G H
 	(r,   c                 v   t               j                  j                  ddd       t        j                  ddddd      }| j                  |j                                | j                  |j                  d   dg       t        j                  dd	ddd      }| j                  |j                                y
)r.   r	   r
   r   r   r   r   r   zNThis email address is already in use. Please supply a different email address.r   N)
r   r   r   r   RegistrationFormUniqueEmailr   r    r!   r"   r#   r1   s     r*   #test_registration_form_unique_emailz9RegistrationFormTests.test_registration_form_unique_emailm   s     	''1DhO005@SDIDI7K L 	)W-jk	m 005@QDIDI7K L 	(r,   c                    dddd}t         j                  j                  D ]o  }|j                         }d|z  |d<   t        j                  |      }| j	                  |j                                | j                  |j                  d   dg       q d|d<   t        j                  |      }| j                  |j                                y)	zv
        Test that ``RegistrationFormNoFreeEmail`` disallows
        registration with free email addresses.

        r   )r   r   r   zfoo@%sr   r   z_Registration using free email addresses is prohibited. Please supply a different email address.r   N)	r   RegistrationFormNoFreeEmailbad_domainscopyr   r    r!   r"   r#   )r$   	base_datadomaininvalid_datar)   s        r*   $test_registration_form_no_free_emailz:RegistrationFormTests.test_registration_form_no_free_email   s     "'"'"')	 77CC 	BF$>>+L$,v$5L!44,GDT]]_-T[[1  AB	B /	'00i@(r,   N)	__name__
__module____qualname____doc__r+   r2   r7   r:   rB    r,   r*   r   r      s!    
0)d)0)*)0)r,   r   )r   django.testr   registrationr   registration.usersr   r   rG   r,   r*   <module>rK      s        (P)H P)r,   