
    GȂi$              	          S SK Jr  S SKJr  S SKJrJr  S SKJr  S SK	J
r
  S SKJr  Sr\" SS	0S
9\" \
R                  /\
R                   /\
R                   /\
R                   /\
R                   /S.S9 " S S\\5      5       5       rg)    )contextmanager)StaticLiveServerTestCase)modify_settingsoverride_settings)SeleniumTestCase)CSP)gettextTappendz5django.middleware.csp.ContentSecurityPolicyMiddleware)
MIDDLEWARE)zdefault-srczconnect-srczimg-srcz
script-srcz	style-src)
SECURE_CSPc                      ^  \ rS rSr/ SQrU 4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r\SS j5       rS rSS jrS rS rSS jrS rS rS rS rSrU =r$ )AdminSeleniumTestCase   )zdjango.contrib.adminzdjango.contrib.authzdjango.contrib.contenttypeszdjango.contrib.sessionszdjango.contrib.sitesc                 `   > U R                  U R                  SS9/ 5        [        TU ]  5         g )Nsecurity)source)assertEqualget_browser_logssupertearDown)self	__class__s    KD:\sksbv-state-backend\venv\Lib\site-packages\django/contrib/admin/tests.pyr   AdminSeleniumTestCase.tearDown"   s,    ..j.A2F    c                 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dmmW-33H=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>8   s    #a&6&6"7;"Fr   N)r#   r   	switch_towindowr)   wait_page_ready)r   r+   r"   s    ` r   wait_for_and_switch_to_popup2AdminSeleniumTestCase.wait_for_and_switch_to_popup2   sG     	FP&&t}}'C'CB'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.byr6   selenium.webdriver.supportr8   r#   presence_of_element_locatedCSS_SELECTORr   css_selectorr"   r6   ecs        r   wait_forAdminSeleniumTestCase.wait_for<   s/     	4H**BOO\+JKW	
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   r5   r7   N)r9   r6   r:   r8   r#   text_to_be_present_in_elementr<   r   r>   textr"   r6   r?   s         r   wait_for_text#AdminSeleniumTestCase.wait_for_textG   s2     	4H,,boo|-Ld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   r5   r7   N)r9   r6   r:   r8   r#   #text_to_be_present_in_element_valuer<   rD   s         r   wait_for_value$AdminSeleniumTestCase.wait_for_valueS   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   r5   r7   N)r9   r6   r:   r8   r#   visibility_of_element_locatedr<   r=   s        r   wait_until_visible(AdminSeleniumTestCase.wait_until_visiblea   s/     	4H,,boo|-LMw	
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   r5   r7   N)r9   r6   r:   r8   r#   invisibility_of_element_locatedr<   r=   s        r   wait_until_invisible*AdminSeleniumTestCase.wait_until_invisiblel   s0     	4H../NOQX	
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   r,   7AdminSeleniumTestCase.wait_page_ready.<locals>.<lambda>|   s    6001NOr   N)r#   )r   r"   s     r   r1   %AdminSeleniumTestCase.wait_page_readyw   s     		
r   c              #      #    SSK Jn  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! U a     Nf = f7f)z1
Block until a new page has loaded and is ready.
r   )WebDriverExceptionr5   r7   htmlN)r"   )selenium.common.exceptionsr\   r9   r6   r:   r8   r   find_elementTAG_NAMEr#   staleness_ofr1   )r   r"   r\   r6   r?   old_pages         r   wait_page_loaded&AdminSeleniumTestCase.wait_page_loaded   st     
 	B3H==--bkk6B	OOBOOH5wOG 	W- " 	 		s)   =A; A/ A;/A85A;7A88A;c                 ,   U R                   R                  5       S   nU R                   R                  5       S   nU R                   R                  US-   U5        U R                  5         U R                   R                  X5        U R                  5         g )Nwidthheight   )r   get_window_sizeset_window_sizer1   )r   rf   rg   s      r   trigger_resize$AdminSeleniumTestCase.trigger_resize   sr    --/8..0:%%eai8%%e4r   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   r5   usernamepasswordzLog inz//input[@value="%s"]N)r9   r6   r   getlive_server_urlr_   NAME	send_keys_rc   XPATHclick)r   rn   ro   	login_urlr6   username_inputpassword_input
login_texts           r   admin_login!AdminSeleniumTestCase.admin_login   s     	4D$8$8)DE33BGGZH  *33BGGZH  *x[
""$MM&&0:=eg %$$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   r5   SelectN)r9   r6   selenium.webdriver.support.uir   r   r_   r<   select_by_valuer   selectorvaluer6   r   selects         r   select_option#AdminSeleniumTestCase.select_option   s7    
 	48222??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   r5   r~   N)r9   r6   r   r   r   r_   r<   deselect_by_valuer   s         r   deselect_option%AdminSeleniumTestCase.deselect_option   s7    
 	48222??HMN  'r   c                     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   r5   N)r9   r6   r   r   r(   find_elementsr<   )r   r   countroot_elementr6   s        r   assertCountSeleniumElements1AdminSeleniumTestCase.assertCountSeleniumElements   s>     	4#4t}}**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   r5   r   c                 F   > U R                  TR                  T5      (       + $ r'   )r   r<   )rX   r6   options_selectors    r   r,   <AdminSeleniumTestCase._assertOptionsValues.<locals>.<lambda>   s    v';';)9( $r   )
r9   r6   r   r   r<   r
   get_attributer   disable_implicit_waitr#   )r   r   valuesoptionsactual_valuesoptionr6   s    `    @r   _assertOptionsValues*AdminSeleniumTestCase._assertOptionsValues   s    3mm11"//CSTG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("BFKr   c                 ~    SSK Jn  U R                  R                  UR                  U5      R                  S5      S:H  $ )zS
Return True if the element identified by `selector` has the `disabled`
attribute.
r   r5   disabledtrue)r9   r6   r   r_   r<   r   )r   r   r6   s      r   is_disabled!AdminSeleniumTestCase.is_disabled   s>    
 	4 MM&&rAOO 	
r    )
   )   r   )z/admin/r'   )__name__
__module____qualname____firstlineno__available_appsr   r#   r2   r@   rF   rJ   rN   rR   r1   r   rc   rk   r{   r   r   r   r   r   r   r   __static_attributes____classcell__)r   s   @r   r   r      s    N
	>	



	
	

 . .*"	&	(
(DL
 
r   r   N)
contextlibr   "django.contrib.staticfiles.testingr   django.testr   r   django.test.seleniumr   django.utils.cspr   django.utils.translationr	   rt   
__unittestNONESELFr   r   r   r   <module>r      s    % G : 1   1 
 QR zzHH:xxjhhZh
,.F h
h
r   