https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/contrib/admin/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/admin/__pycache__/tests.cpython-310.pyc
o

�a��@s|ddlmZddlmZddlmZddlmZddlm	Z	ddl
mZGdd�de	�Z
ed	d
id�Gdd
�d
ee��ZdS)�)�contextmanager)�StaticLiveServerTestCase)�modify_settings)�SeleniumTestCase)�MiddlewareMixin)�gettextc@seZdZdZdd�ZdS)�
CSPMiddlewarez5The admin's JavaScript should be compatible with CSP.cCsd|jd<|S)Nzdefault-src 'self'zContent-Security-Policy)�headers)�self�request�response�r
�</usr/lib/python3/dist-packages/django/contrib/admin/tests.py�process_responses
zCSPMiddleware.process_responseN)�__name__�
__module__�__qualname__�__doc__rr
r
r
rr
sr�appendz(django.contrib.admin.tests.CSPMiddleware)�
MIDDLEWAREc@s�eZdZgd�Zd&dd�Zd'dd�Zd&dd	�Zd&d
d�Zd&dd
�Zd&dd�Z	d&dd�Z
d&dd�Zed&dd��Z
d(dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%S))�AdminSeleniumTestCase)zdjango.contrib.adminzdjango.contrib.authzdjango.contrib.contenttypeszdjango.contrib.sessionszdjango.contrib.sites�
cCs"ddlm}||j|��|�dS)a%
        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�timeoutrr
r
r�
wait_untilsz AdminSeleniumTestCase.wait_until�cs6|��fdd�|�|jj�|jjd�|��dS)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.
        cst|j��kS�N)�len�window_handles)�d��num_windowsr
r�<lambda>,�zDAdminSeleniumTestCase.wait_for_and_switch_to_popup.<locals>.<lambda>���N)rr�	switch_to�windowr"�wait_page_ready)r
r%rr
r$r�wait_for_and_switch_to_popup&sz2AdminSeleniumTestCase.wait_for_and_switch_to_popupcC�4ddlm}ddlm}|�|�|j|f�|�dS)zB
        Block until a CSS selector is found on the page.
        r��By��expected_conditionsN)�selenium.webdriver.common.byr/�selenium.webdriver.supportr1r�presence_of_element_located�CSS_SELECTOR�r
�css_selectorrr/�ecr
r
r�wait_for0��zAdminSeleniumTestCase.wait_forcC�6ddlm}ddlm}|�|�|j|f|�|�dS)zD
        Block until the text is found in the CSS selector.
        rr.r0N)r2r/r3r1r�text_to_be_present_in_elementr5�r
r7�textrr/r8r
r
r�
wait_for_text;�
��z#AdminSeleniumTestCase.wait_for_textcCr;)zE
        Block until the value is found in the CSS selector.
        rr.r0N)r2r/r3r1r�#text_to_be_present_in_element_valuer5r=r
r
r�wait_for_valueGr@z$AdminSeleniumTestCase.wait_for_valuecCr-)zS
        Block until the element described by the CSS selector is visible.
        rr.r0N)r2r/r3r1r�visibility_of_element_locatedr5r6r
r
r�wait_until_visibleSr:z(AdminSeleniumTestCase.wait_until_visiblecCr-)zU
        Block until the element described by the CSS selector is invisible.
        rr.r0N)r2r/r3r1r�invisibility_of_element_locatedr5r6r
r
r�wait_until_invisible^r:z*AdminSeleniumTestCase.wait_until_invisiblecCs|�dd�|�dS)z1
        Block until the  page is ready.
        cSs|�d�dkS)Nzreturn document.readyState;�complete)�execute_script��driverr
r
rr&nr'z7AdminSeleniumTestCase.wait_page_ready.<locals>.<lambda>N)r)r
rr
r
rr+is�z%AdminSeleniumTestCase.wait_page_readyccsD�ddlm}|j�d�}dV|j|�|�|d�|j|d�dS)zA
        Block until a new page has loaded and is ready.
        rr0�htmlN)r)r3r1r�find_element_by_tag_namer�staleness_ofr+)r
rr8�old_pager
r
r�wait_page_loadedrs�z&AdminSeleniumTestCase.wait_page_loaded�/admin/cCs�|j�d|j|f�|j�d�}|�|�|j�d�}|�|�td�}|���|j�d|���Wd�dS1s?wYdS)z&
        Log in to the admin.
        z%s%s�username�passwordzLog inz//input[@value="%s"]N)	r�get�live_server_url�find_element_by_name�	send_keys�_rO�find_element_by_xpath�click)r
rQrR�	login_url�username_input�password_input�
login_textr
r
r�admin_login~s


"�z!AdminSeleniumTestCase.admin_logincC�*ddlm}||j�|��}|�|�dS)z�
        Select the <OPTION> with the value `value` inside the <SELECT> widget
        identified by the CSS selector `selector`.
        r��SelectN)�selenium.webdriver.support.uirar�find_element_by_css_selector�select_by_value�r
�selector�valuera�selectr
r
r�
select_option��z#AdminSeleniumTestCase.select_optioncCr_)z�
        Deselect the <OPTION> with the value `value` inside the <SELECT> widget
        identified by the CSS selector `selector`.
        rr`N)rbrarrc�deselect_by_valuerer
r
r�deselect_option�rjz%AdminSeleniumTestCase.deselect_optioncs~|r|j���}g}|D]
}|�|�d��q|�||�dS|���|��fdd��Wd�dS1s8wYdS)Nrgcs|���Sr )�find_elements_by_css_selectorrI��options_selectorr
rr&�sz<AdminSeleniumTestCase._assertOptionsValues.<locals>.<lambda>)rrmr�
get_attribute�assertEqual�disable_implicit_waitr)r
ro�values�options�
actual_values�optionr
rnr�_assertOptionsValues�s

�"�z*AdminSeleniumTestCase._assertOptionsValuescC�|�d||�dS)z{
        Assert that the <SELECT> widget identified by `selector` has the
        options with the given `values`.
        z%s > optionN�rw�r
rfrsr
r
r�assertSelectOptions��z)AdminSeleniumTestCase.assertSelectOptionscCrx)z�
        Assert that the <SELECT> widget identified by `selector` has the
        selected options with the given `values`.
        z%s > option:checkedNryrzr
r
r�assertSelectedOptions�r|z+AdminSeleniumTestCase.assertSelectedOptionscCs|j�|��d��|�dkS)zh
        Return True if the element identified by `selector` has the CSS class
        `klass`.
        �classr()rrcrp�find)r
rf�klassr
r
r�
has_css_class�s
�z#AdminSeleniumTestCase.has_css_classN)r)rr)rP)rrr�available_appsrr,r9r?rBrDrFr+rrOr^rirlrwr{r}r�r
r
r
rrs&









	

		rN)�
contextlibr�"django.contrib.staticfiles.testingr�django.testr�django.test.seleniumr�django.utils.deprecationr�django.utils.translationrrWrrr
r
r
r�<module>s

https://t.me/RX1948 - 2025