
    .~h                         d dl mZ d dlmZ d dlmZ d dlmZ ddlm	Z	 d dl
mZ d dlmZ d d	lmZ d
 Z ed       G d de	             Zy)    )settings)mail)override_settings)reverse   )DefaultBackendViewTests)RegistrationView)SupervisedRegistrationProfile)	UserModelc                  
    ddgS )zC
    Mock function for testing the admin getter functionality

    )zFunctional admin 1zfunc_admin1@fakemail.com)zFunctional admin 2zfunc_admin2@fakemail.com r       r/var/www/peopleoo.sandbox-dev.co.uk/venv/lib/python3.12/site-packages/registration/tests/admin_approval_backend.pyget_registration_adminsr      s     	;: r   ztest_app.urls_admin_approval)ROOT_URLCONFc                   ^    e Zd ZdZeZeZd Z e	ddg      d        Z
 e	d      d        Zy	)
AdminApprovalBackendViewTestsa"  
    Test the admin_approval registration backend.

    Running these tests successfully will require two templates to be
    created for the sending of activation emails; details on these
    templates and their contexts may be found in the documentation for
    the default backend.

    c                    | j                   j                  t        d      ddddd      }| j                  j                  j                  d      }| j                  |j                  j                         | j                   j                  t        dd	d
|j                  i            }t               j                  j                  ddd      }| j                   j                  |j                         |       | j                   j                  t        dd	d|j                  i            }|j                  j                          | j!                  |j                  j                         | j#                  |t        d             y)z=
        Approval of an account functions properly.

        registration_registerbobbob@example.comsecretusernameemail	password1	password2datauser__usernameregistration_activater   activation_keyargskwargsadminzadmin@test.com)r   passwordregistration_admin_approve
profile_idregistration_approve_completeN)clientpostr   registration_profileobjectsgetassertFalseuser	is_activer#   r   create_superuserloginget_usernameidrefresh_from_db
assertTrueassertRedirects)selfrespprofile
admin_users       r   test_approvalz+AdminApprovalBackendViewTests.test_approval(   sI   
 {{(? @27/@3;3;&=   > ++3377u7M//0{{+,g.D.DEGH
 [((99'CSU\]
:#:#:#<zR{{0('**578 	$$&../T7+J#KLr   )z	The adminzadmin_alpha@fakemail.com)zThe other adminzadmin_two@fakemail.com)REGISTRATION_ADMINSc                    | j                   j                  t        d      ddddd      }| j                  j                  j                  d      }| j                   j                  t        dd	d
|j                  i            }| j                  |t        d             t        j                  d   }| j                  |j                  t        j                  D cg c]  }|d   	 c}       yc c}w )zM
        Admins are pulled from the REGISTRATION_ADMINS list setting
        r   r   r   r   r   r   r    r"   r   r#   r$    registration_activation_completer   N)r,   r-   r   r.   r/   r0   r#   r:   r   outboxassertEqualtor   r@   r;   r<   r=   admins_mailrE   s        r   test_admins_when_is_listz6AdminApprovalBackendViewTests.test_admins_when_is_listF   s     {{(? @27/@3;3;&=   > ++3377u7M{{+,g.D.DEGH 	T7+M#NOkk!n(:V:V)WB"Q%)WX)Ws   C/
zAregistration.tests.admin_approval_backend.get_registration_adminsc                    | j                   j                  t        d      ddddd      }| j                  j                  j                  d      }| j                   j                  t        dd	d
|j                  i            }| j                  |t        d             t        j                  d   }| j                  |j                  t               D cg c]  }|d   	 c}       yc c}w )zO
        Admins are pulled from the REGISTRATION_ADMINS string setting
        r   r   r   r   r   r   r    r"   r   r#   r$   rB   r   N)r,   r-   r   r.   r/   r0   r#   r:   r   rC   rD   rE   r   rF   s        r   test_admins_when_is_getterz8AdminApprovalBackendViewTests.test_admins_when_is_getter`   s     {{(? @27/@3;3;&=   > ++3377u7M{{+,g.D.DEGH 	T7+M#NOkk!n:Q:S)TB"Q%)TU)Ts   C)
N)__name__
__module____qualname____doc__r
   r.   r	   registration_viewr?   r   rH   rJ   r   r   r   r   r      s_     9(M< 59
YY( _VVr   r   N)django.confr   django.corer   django.test.utilsr   django.urlsr   default_backendr   *registration.backends.admin_approval.viewsr	   registration.modelsr
   registration.usersr   r   r   r   r   r   <module>rX      sK       /  4 G = (  >?\V$; \V @\Vr   