
    0h'                    j   S SK Jr  S SKrS SK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K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KJr  \R6                  (       a  S SKJr  S SKJr  SSKJ r    " S S\RB                  RD                  5      r"Sq#SS jr$ " S S\5      r% " S S\5      r&g)    )annotationsN)contextmanager)	ExitStack)copy)TracebackType)urlsplit)	CliRunner)Result)Client)Request   )
ScriptInfo)SessionMixin)WSGIEnvironment)TestResponse)Flaskc                  d   ^  \ rS rSrSr    S               SU 4S jjjrSS jrSrU =r$ )	EnvironBuilder   au  An :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the
application.

:param app: The Flask application to configure the environment from.
:param path: URL path being requested.
:param base_url: Base URL where the app is being served, which
    ``path`` is relative to. If not given, built from
    :data:`PREFERRED_URL_SCHEME`, ``subdomain``,
    :data:`SERVER_NAME`, and :data:`APPLICATION_ROOT`.
:param subdomain: Subdomain name to append to :data:`SERVER_NAME`.
:param url_scheme: Scheme to use instead of
    :data:`PREFERRED_URL_SCHEME`.
:param json: If given, this is serialized as JSON and passed as
    ``data``. Also defaults ``content_type`` to
    ``application/json``.
:param args: other positional arguments passed to
    :class:`~werkzeug.test.EnvironBuilder`.
:param kwargs: other keyword arguments passed to
    :class:`~werkzeug.test.EnvironBuilder`.
c                B  > U(       d  U(       d  U(       a!  US L[        U=(       d    U5      :w  d   S5       eUc  UR                  R                  S5      =(       d    SnUR                  S   n	U(       a  U SU 3nUc  UR                  S   n[        U5      n
U
R                  =(       d    U SU
R
                  =(       d    U SU	R                  S5       3nU
R                  nU
R                  (       a  U S	U
R                   3nXl	        [        TU ],  " X#/UQ70 UD6  g )
Nz8Cannot pass "subdomain" or "url_scheme" with "base_url".SERVER_NAME	localhostAPPLICATION_ROOT.PREFERRED_URL_SCHEMEz:///?)boolconfiggetr   schemenetloclstrippathqueryappsuper__init__)selfr&   r$   base_url	subdomain
url_schemeargskwargs	http_hostapp_rooturl	__class__s              E/var/www/auris/envauris/lib/python3.13/site-packages/flask/testing.pyr(   EnvironBuilder.__init__1   s    	ZD ))z*=+ 	
 G	
 + 

}5DIzz"45H(k9+6	! ZZ(>?
4.C::+,C

0Gi/HHOOC()+  88Dyyq,9$9&9    c                P    U R                   R                  R                  " U40 UD6$ )zSerialize ``obj`` to a JSON-formatted string.

The serialization will be configured according to the config associated
with this EnvironBuilder's ``app``.
)r&   jsondumps)r)   objr.   s      r3   
json_dumpsEnvironBuilder.json_dumpsX   s"     xx}}""31&11r5   r&   )r   NNN)r&   r   r$   strr*   
str | Noner+   r>   r,   r>   r-   t.Anyr.   r?   returnNone)r9   r?   r.   r?   r@   r=   )	__name__
__module____qualname____firstlineno____doc__r(   r:   __static_attributes____classcell__r2   s   @r3   r   r      sy    0 # $!%%:%: %: 	%:
 %: %: %: %: 
%: %:N2 2r5   r    c                 b    [         (       d  [        R                  R                  S5      q [         $ )Nwerkzeug)_werkzeug_version	importlibmetadataversion r5   r3   _get_werkzeug_versionrR   d   s'     %..66zBr5   c                     ^  \ rS rSr% SrS\S'   SU 4S jjr\      SS j5       rSS jr	      SS jr
S	S	S
.         SU 4S jjjrSS jr        SS jrSrU =r$ )FlaskClientm   a  Works like a regular Werkzeug test client but has knowledge about
Flask's contexts to defer the cleanup of the request context until
the end of a ``with`` block. For general information about how to
use this class refer to :class:`werkzeug.test.Client`.

.. versionchanged:: 0.12
   `app.test_client()` includes preset default environment, which can be
   set after instantiation of the `app.test_client()` object in
   `client.environ_base`.

Basic usage is outlined in the :doc:`/testing` chapter.
r   applicationc                   > [         TU ]  " U0 UD6  SU l        / U l        [	        5       U l        SS[        5        3S.U l        g )NFz	127.0.0.1z	Werkzeug/)REMOTE_ADDRHTTP_USER_AGENT)r'   r(   preserve_context_new_contextsr   _context_stackrR   environ_base)r)   r-   r.   r2   s      r3   r(   FlaskClient.__init__}   sK    $)&) %<>'k&!*+@+B*CD
r5   c              /    #    U R                   c  [        S5      eU R                  nUR                  " U0 UD6nU R	                  UR
                  R                  5        U   UR                  R                  X4R
                  5      nSSS5        Wc  [        S5      eUv   UR                  5       nUR                  R                  U5      (       a  gU   UR                  R                  X5U5        SSS5        U R                  UR
                  R                  R                  S5      S   UR
                  R                   UR"                  R%                  S5      5        g! , (       d  f       N= f! , (       d  f       N= f7f)a2  When used in combination with a ``with`` statement this opens a
session transaction.  This can be used to modify the session that
the test client uses.  Once the ``with`` block is left the session is
stored back.

::

    with client.session_transaction() as session:
        session['value'] = 42

Internally this is implemented by going through a temporary test
request context and since session handling could depend on
request variables this function accepts the same arguments as
:meth:`~flask.Flask.test_request_context` which are directly
passed through.
Nz>Cookies are disabled. Create a client with 'use_cookies=True'.z'Session backend did not open a session.:r   z
Set-Cookie)_cookies	TypeErrorrV   test_request_context_add_cookies_to_wsgirequestenvironsession_interfaceopen_sessionRuntimeErrorresponse_classis_null_sessionsave_session_update_cookies_from_responsehost	partitionr$   headersgetlist)r)   r-   r.   r&   ctxsessresps          r3   session_transactionFlaskClient.session_transaction   s6    ( == P  &&77!!#++"5"56((55c;;GD  <HII
!!#  0066!!..s$?  	**KK&&s+A.KKLL  .	
 S Ss8   AF &EAFE00A/F
E-)F0
E>:Fc                z    0 U R                   EUEnU R                  (       a  U R                  R                  US'   U$ )Nzwerkzeug.debug.preserve_context)r]   rZ   r[   append)r)   otherouts      r3   _copy_environFlaskClient._copy_environ   s<    ,"",e,  595G5G5N5NC12
r5   c                    U R                  UR                  S0 5      5      US'   [        U R                  /UQ70 UD6n UR	                  5       UR                  5         $ ! UR                  5         f = f)Nr]   )r{   r    r   rV   get_requestclose)r)   r-   r.   builders       r3   _request_from_builder_args&FlaskClient._request_from_builder_args   sb     "&!3!3FJJ~r4R!S~ !1!1CDCFC	&&(MMOGMMOs   A A1Fbufferedfollow_redirectsc                 > U(       Ga2  [        US   [        R                  R                  [        [
        45      (       a  [        US   [        R                  R                  5      (       aH  [        US   5      nU R                  UR                  =(       d    0 5      Ul        UR                  5       nO[        US   [        5      (       a@  [        R                  US   U R                  U R                  0 5      S9R                  5       nO@[        US   5      nU R                  UR                  5      Ul        OU R                  X45      nU R                  R                  5         [         T	U ]E  UUUS9nU R                  R$                  Ul        U R(                  (       aH  U R(                  R+                  5       nU R                  R-                  U5        U R(                  (       a  MH  U$ )Nr   )r&   r]   r   )
isinstancerL   testr   dictBaseRequestr   r{   r]   r~   from_environrV   rf   r   r\   r   r'   openr7   json_moduler[   popenter_context)
r)   r   r   r-   r.   r   re   responsecmr2   s
            r3   r   FlaskClient.open   s    JGhmm22D+F
 
 $q'8==#?#?@@tAw-'+'9'9':N:N:TRT'U$!--/DGT**(55G!1!1@R@RSU@V 6 +- 
 tAw-"&"4"4W__"E 55dCG
 	!!#7<-   

  $//44   ##'')B--b1     r5   c                L    U R                   (       a  [        S5      eSU l         U $ )NzCannot nest client invocationsT)rZ   ri   r)   s    r3   	__enter__FlaskClient.__enter__   s$      ?@@ $r5   c                F    SU l         U R                  R                  5         g )NF)rZ   r\   r   )r)   exc_type	exc_valuetbs       r3   __exit__FlaskClient.__exit__   s     !&!!#r5   )r\   r[   r]   rZ   )r-   r?   r.   r?   r@   rA   )r-   r?   r.   r?   r@   zt.Iterator[SessionMixin])ry   r   r@   r   )r-   ztuple[t.Any, ...]r.   zdict[str, t.Any]r@   r   )
r-   r?   r   r   r   r   r.   r?   r@   r   )r@   rT   )r   ztype | Noner   zBaseException | Noner   zTracebackType | Noner@   rA   )rB   rC   rD   rE   rF   __annotations__r(   r   ru   r{   r   r   r   r   rG   rH   rI   s   @r3   rT   rT   m   s     
 /
/
&+/
	!/
 /
b	%	/?			 !&	++ + 	+
 + 
+ +Z$$ ($ !	$
 
$ $r5   rT   c                  T   ^  \ rS rSrSrSU 4S jjr S       SU 4S jjjrSrU =r$ )	FlaskCliRunneri	  zA :class:`~click.testing.CliRunner` for testing a Flask app's
CLI commands. Typically created using
:meth:`~flask.Flask.test_cli_runner`. See :ref:`testing-cli`.
c                2   > Xl         [        TU ]  " S0 UD6  g )NrQ   )r&   r'   r(   )r)   r&   r.   r2   s      r3   r(   FlaskCliRunner.__init__  s    "6"r5   c                   >^  Uc  T R                   R                  nSU;  a  [        U 4S jS9US'   [        TT ]  " X40 UD6$ )a  Invokes a CLI command in an isolated environment. See
:meth:`CliRunner.invoke <click.testing.CliRunner.invoke>` for
full method documentation. See :ref:`testing-cli` for examples.

If the ``obj`` argument is not given, passes an instance of
:class:`~flask.cli.ScriptInfo` that knows how to load the Flask
app being tested.

:param cli: Command object to invoke. Default is the app's
    :attr:`~flask.app.Flask.cli` group.
:param args: List of strings to invoke the command with.

:return: a :class:`~click.testing.Result` object.
r9   c                    > T R                   $ )Nr<   r   s   r3   <lambda>'FlaskCliRunner.invoke.<locals>.<lambda>(  s	    $((r5   )
create_app)r&   clir   r'   invoke)r)   r   r-   r.   r2   s   `   r3   r   FlaskCliRunner.invoke  sB    " ;((,,C&2BCF5Mw~c2622r5   r<   )r&   r   r.   r?   r@   rA   )NN)r   r?   r-   r?   r.   r?   r@   r
   )	rB   rC   rD   rE   rF   r(   r   rG   rH   rI   s   @r3   r   r   	  s<    
#
 0433',3?D3	3 3r5   r   )r@   r=   )'
__future__r   importlib.metadatarN   typingt
contextlibr   r   r   typesr   urllib.parser   werkzeug.testrL   click.testingr	   r
   r   werkzeug.wrappersr   r   r   r   sessionsr   TYPE_CHECKING_typeshed.wsgir   r   r&   r   r   r   rM   rR   rT   r   rQ   r5   r3   <module>r      s    "   %     !  #     4  "??.*C2X]]11 C2L  Y$& Y$x!3Y !3r5   