ó
    ®RjL!  ã                   ó�   • S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr   " S S\	5      r\" S	S
0S9 " S S\\5      5       rg)é    )Úcontextmanager)ÚStaticLiveServerTestCase)Úmodify_settings)ÚSeleniumTestCase)ÚMiddlewareMixin)Úgettextc                   ó   • \ rS rSrSrS rSrg)ÚCSPMiddlewareé
   z5The admin's JavaScript should be compatible with CSP.c                 ó$   • SUR                   S'   U$ )Nzdefault-src 'self'zContent-Security-Policy)Úheaders)ÚselfÚrequestÚresponses      ÚFD:\diplom_project\venv\Lib\site-packages\django/contrib/admin/tests.pyÚprocess_responseÚCSPMiddleware.process_response   s   € Ø6Jˆ×ÑÐ2Ñ3Øˆó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__r   r   r   r
   r
   
   s
   † Ù?õr   r
   Úappendz(django.contrib.admin.tests.CSPMiddleware)Ú
MIDDLEWAREc                   ó¸   • \ rS rSr/ SQrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jr\SS j5       rSS jrS rS rSS jrS rS rS rS rSrg)ÚAdminSeleniumTestCaseé   )zdjango.contrib.adminzdjango.contrib.authzdjango.contrib.contenttypeszdjango.contrib.sessionszdjango.contrib.sitesc                 óT   • SSK Jn  U" U R                  U5      R                  U5        g)zý
Block the execution of the tests until the specified callback returns a
value that is not falsy. This method can be called, for example, after
clicking a link or submitting a form. See the other public methods that
call this function for more details.
r   )ÚWebDriverWaitN)Úselenium.webdriver.support.waitr"   ÚseleniumÚuntil)r   ÚcallbackÚtimeoutr"   s       r   Ú
wait_untilÚ AdminSeleniumTestCase.wait_until   s!   € õ 	Bá�d—m‘m WÓ-×3Ñ3°HÕ=r   c                 óÊ   ^• U R                  U4S jU5        U R                  R                  R                  U R                  R                  S   5        U R                  5         g)z³
Block until `num_windows` are present and are ready (usually 2, but can
be overridden in the case of pop-ups opening other pop-ups). Switch the
current window to the new pop-up.
c                 ó4   >• [        U R                  5      T:H  $ ©N)ÚlenÚwindow_handles)ÚdÚnum_windowss    €r   Ú<lambda>ÚDAdminSeleniumTestCase.wait_for_and_switch_to_popup.<locals>.<lambda>-   s   ø€ ¤# a×&6Ñ&6Ó"7¸;Ò"Fr   éÿÿÿÿN)r(   r$   Ú	switch_toÚwindowr.   Úwait_page_ready)r   r0   r'   s    ` r   Úwait_for_and_switch_to_popupÚ2AdminSeleniumTestCase.wait_for_and_switch_to_popup'   sG   ø€ ð 	�‰ÔFÈÔPØ�‰×Ñ×&Ñ& t§}¡}×'CÑ'CÀBÑ'GÔHØ×ÑÕr   c                 óv   • SSK Jn  SSKJn  U R	                  UR                  UR                  U45      U5        g)z2
Block until a CSS selector is found on the page.
r   ©ÚBy©Úexpected_conditionsN)Úselenium.webdriver.common.byr;   Úselenium.webdriver.supportr=   r(   Úpresence_of_element_locatedÚCSS_SELECTOR©r   Úcss_selectorr'   r;   Úecs        r   Úwait_forÚAdminSeleniumTestCase.wait_for1   s/   € õ 	4ÝHà�‰Ø×*Ñ*¨B¯O©O¸\Ð+JÓKÈWõ	
r   c                 óx   • SSK Jn  SSKJn  U R	                  UR                  UR                  U4U5      U5        g)z4
Block until the text is found in the CSS selector.
r   r:   r<   N)r>   r;   r?   r=   r(   Útext_to_be_present_in_elementrA   ©r   rC   Útextr'   r;   rD   s         r   Úwait_for_textÚ#AdminSeleniumTestCase.wait_for_text<   s2   € õ 	4ÝHà�‰Ø×,Ñ,¨b¯o©o¸|Ð-LÈdÓSØõ	
r   c                 óx   • SSK Jn  SSKJn  U R	                  UR                  UR                  U4U5      U5        g)z5
Block until the value is found in the CSS selector.
r   r:   r<   N)r>   r;   r?   r=   r(   Ú#text_to_be_present_in_element_valuerA   rI   s         r   Úwait_for_valueÚ$AdminSeleniumTestCase.wait_for_valueH   s7   € õ 	4ÝHà�‰Ø×2Ñ2Ø—‘ ,Ð/°óð õ		
r   c                 óv   • SSK Jn  SSKJn  U R	                  UR                  UR                  U45      U5        g)zC
Block until the element described by the CSS selector is visible.
r   r:   r<   N)r>   r;   r?   r=   r(   Úvisibility_of_element_locatedrA   rB   s        r   Úwait_until_visibleÚ(AdminSeleniumTestCase.wait_until_visibleV   s/   € õ 	4ÝHà�‰Ø×,Ñ,¨b¯o©o¸|Ð-LÓMÈwõ	
r   c                 óv   • SSK Jn  SSKJn  U R	                  UR                  UR                  U45      U5        g)zE
Block until the element described by the CSS selector is invisible.
r   r:   r<   N)r>   r;   r?   r=   r(   Úinvisibility_of_element_locatedrA   rB   s        r   Úwait_until_invisibleÚ*AdminSeleniumTestCase.wait_until_invisiblea   s0   € õ 	4ÝHà�‰Ø×.Ñ.°·±ÀÐ/NÓOÐQXõ	
r   c                 ó*   • U R                  S U5        g)z!
Block until the  page is ready.
c                 ó*   • U R                  S5      S:H  $ )Nzreturn document.readyState;Úcomplete)Úexecute_script)Údrivers    r   r1   Ú7AdminSeleniumTestCase.wait_page_ready.<locals>.<lambda>q   s   € ˜6×0Ñ0Ð1NÓOØòr   N)r(   )r   r'   s     r   r6   Ú%AdminSeleniumTestCase.wait_page_readyl   s   € ð 	�‰ñàõ	
r   c              #   óÔ   #   • SSK Jn  SSKJn  U R                  R                  UR                  S5      nSv •  U R                  UR                  U5      US9  U R                  US9  g7f)z1
Block until a new page has loaded and is ready.
r   r:   r<   ÚhtmlN)r'   )
r>   r;   r?   r=   r$   Úfind_elementÚTAG_NAMEr(   Ústaleness_ofr6   )r   r'   r;   rD   Úold_pages        r   Úwait_page_loadedÚ&AdminSeleniumTestCase.wait_page_loadedv   sT   é € õ
 	4ÝHà—=‘=×-Ñ-¨b¯k©k¸6ÓBˆÛà�‰˜Ÿ™¨Ó1¸7ˆÑCØ×Ñ WÐÒ-ùs   ‚A&A(c                 ó  • SSK Jn  U R                  R                  U R                  < U< 35        U R                  R                  UR                  S5      nUR                  U5        U R                  R                  UR                  S5      nUR                  U5        [        S5      nU R                  5          U R                  R                  UR                  SU-  5      R                  5         SSS5        g! , (       d  f       g= f)z
Log in to the admin.
r   r:   ÚusernameÚpasswordzLog inz//input[@value="%s"]N)r>   r;   r$   ÚgetÚlive_server_urlrb   ÚNAMEÚ	send_keysÚ_rf   ÚXPATHÚclick)r   ri   rj   Ú	login_urlr;   Úusername_inputÚpassword_inputÚ
login_texts           r   Úadmin_loginÚ!AdminSeleniumTestCase.admin_login„   s½   € õ 	4à�‰×Ñ D×$8Ó$8º)ÐDÔEØŸ™×3Ñ3°B·G±G¸ZÓHˆØ× Ñ  Ô*ØŸ™×3Ñ3°B·G±G¸ZÓHˆØ× Ñ  Ô*Ü�x“[ˆ
Ø×"Ñ"Õ$Ø�M‰M×&Ñ&Ø—‘Ð0°:Ñ=óç‰eŒg÷ %×$Ö$ús   Â;8C<Ã<
D
c                 ó–   • SSK Jn  SSKJn  U" U R                  R                  UR                  U5      5      nUR                  U5        g)zr
Select the <OPTION> with the value `value` inside the <SELECT> widget
identified by the CSS selector `selector`.
r   r:   ©ÚSelectN)r>   r;   Úselenium.webdriver.support.uirz   r$   rb   rA   Úselect_by_value©r   ÚselectorÚvaluer;   rz   Úselects         r   Úselect_optionÚ#AdminSeleniumTestCase.select_option•   s7   € õ
 	4Ý8á˜Ÿ™×2Ñ2°2·?±?ÀHÓMÓNˆØ×Ñ˜uÕ%r   c                 ó–   • SSK Jn  SSKJn  U" U R                  R                  UR                  U5      5      nUR                  U5        g)zt
Deselect the <OPTION> with the value `value` inside the <SELECT> widget
identified by the CSS selector `selector`.
r   r:   ry   N)r>   r;   r{   rz   r$   rb   rA   Údeselect_by_valuer}   s         r   Údeselect_optionÚ%AdminSeleniumTestCase.deselect_option    s7   € õ
 	4Ý8á˜Ÿ™×2Ñ2°2·?±?ÀHÓMÓNˆØ× Ñ  Õ'r   Nc                 ó¤   • SSK Jn  U=(       d    U R                  nU R                  [	        UR                  UR                  U5      5      U5        g)zh
Assert number of matches for a CSS selector.

`root_element` allow restriction to a pre-selected node.
r   r:   N)r>   r;   r$   ÚassertEqualr-   Úfind_elementsrA   )r   r~   ÚcountÚroot_elementr;   s        r   ÚassertCountSeleniumElementsÚ1AdminSeleniumTestCase.assertCountSeleniumElements«   s>   € õ 	4à#×4 t§}¡}ˆØ×ÑÜ�×*Ñ*¨2¯?©?¸HÓEÓFÈõ	
r   c                 óh  ^^• SSK Jm  U(       ac  U R                  R                  TR                  T5      n/ nU H#  nUR                  UR                  S5      5        M%     U R                  X$5        g U R                  5          U R                  UU4S j5        S S S 5        g ! , (       d  f       g = f)Nr   r:   r   c                 óF   >• U R                  TR                  T5      (       + $ r,   )r‰   rA   )r]   r;   Úoptions_selectors    €€r   r1   Ú<AdminSeleniumTestCase._assertOptionsValues.<locals>.<lambda>Ç   s   ø€  v×';Ñ';ØŸ™Ð)9ó(õ $r   )
r>   r;   r$   r‰   rA   r   Úget_attributerˆ   Údisable_implicit_waitr(   )r   r�   ÚvaluesÚoptionsÚactual_valuesÚoptionr;   s    `    @r   Ú_assertOptionsValuesÚ*AdminSeleniumTestCase._assertOptionsValues¸   s…   ù€ Ý3æØ—m‘m×1Ñ1°"·/±/ÐCSÓTˆGØˆMÛ!�Ø×$Ñ$ V×%9Ñ%9¸'Ó%BÖCñ "à×Ñ˜VÕ3ð
 ×+Ñ+Õ-Ø—‘õô÷ .×-Ö-ús   ÂB#Â#
B1c                 ó.   • U R                  SU-  U5        g)zc
Assert that the <SELECT> widget identified by `selector` has the
options with the given `values`.
z%s > optionN©r˜   ©r   r~   r”   s      r   ÚassertSelectOptionsÚ)AdminSeleniumTestCase.assertSelectOptionsÌ   s   € ð
 	×!Ñ! -°(Ñ":¸FÕCr   c                 ó.   • U R                  SU-  U5        g)zl
Assert that the <SELECT> widget identified by `selector` has the
selected options with the given `values`.
z%s > option:checkedNr›   rœ   s      r   ÚassertSelectedOptionsÚ+AdminSeleniumTestCase.assertSelectedOptionsÓ   s   € ð
 	×!Ñ!Ð"7¸(Ñ"BÀFÕKr   c                 óœ   • SSK Jn  U R                  R                  UR                  U5      R                  S5      R                  U5      S:g  $ )zP
Return True if the element identified by `selector` has the CSS class
`klass`.
r   r:   Úclassr3   )r>   r;   r$   rb   rA   r’   Úfind)r   r~   Úklassr;   s       r   Úhas_css_classÚ#AdminSeleniumTestCase.has_css_classÚ   sG   € õ
 	4ð �M‰M×&Ñ&Ø—‘Øó÷ ‰]˜7Ó#ß‰T�%‹[Øñð	
r   r   )r   )é   r   )z/admin/r,   )r   r   r   r   Úavailable_appsr(   r7   rE   rK   rO   rS   rW   r6   r   rf   rv   r�   r…   rŒ   r˜   r�   r    r¦   r   r   r   r   r   r      so   † ò€Nô	>ôô	
ô

ô
ô	
ô	
ô
ð ó.ó ð.ôò"	&ò	(ô
òò(DòLõ
r   r   N)Ú
contextlibr   Ú"django.contrib.staticfiles.testingr   Údjango.testr   Údjango.test.seleniumr   Údjango.utils.deprecationr   Údjango.utils.translationr   ro   r
   r   r   r   r   Ú<module>r°      sQ   ðÝ %å GÝ 'Ý 1Ý 4Ý 1ô�Oô ñ ˜XÐ'QÐRÑSôV
Ð,Ð.Fó V
ó TñV
r   