ó
    ×›‘h.  ã                   óî   • S r SSKJr  SSKJr  SSKJr   " S S\R                  5      r " S S5      r	 " S	 S
\	\R                  5      r
 " S S\	\R                  5      r " S S\	\R                  5      rg)z)
Tests L{twisted.web.client} helper APIs
é    )Úurlparse)Úunittest)Úclientc                   ó$   • \ rS rSrSrS rS rSrg)ÚURLJoinTestsé   z
Tests for L{client._urljoin}.
c                 óî   • U R                  [        R                  " SS5      S5        U R                  [        R                  " SS5      S5        U R                  [        R                  " SS5      S5        g)z”
L{client._urljoin} does not include a fragment identifier in the
resulting URL if neither the base nor the new path include a fragment
identifier.
ó   http://foo.com/baró   /quuxs   http://foo.com/quuxs   http://foo.com/bar#s   /quux#N©ÚassertEqualr   Ú_urljoin©Úselfs    ÚcC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/web/test/test_webclient.pyÚtest_noFragmentsÚURLJoinTests.test_noFragments   sh   € ð 	×ÑÜ�OŠOÐ1°8Ó<Ð>Tô	
ð 	×ÑÜ�OŠOÐ2°HÓ=Ð?Uô	
ð 	×ÑÜ�OŠOÐ1°9Ó=Ð?Uõ	
ó    c                 óî   • U R                  [        R                  " SS5      S5        U R                  [        R                  " SS5      S5        U R                  [        R                  " SS5      S5        g)zì
L{client._urljoin} preserves the fragment identifier from either the
new path or the base URL respectively, as specified in the HTTP 1.1 bis
draft.

@see: U{https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-22#section-7.1.2}
s   http://foo.com/bar#fragr   s   http://foo.com/quux#fragr
   s   /quux#frag2s   http://foo.com/quux#frag2Nr   r   s    r   Útest_preserveFragmentsÚ#URLJoinTests.test_preserveFragments$   sh   € ð 	×ÑÜ�OŠOÐ6¸ÓAØ'ô	
ð 	×ÑÜ�OŠOÐ1°>ÓBØ(ô	
ð 	×ÑÜ�OŠOÐ6¸ÓGØ(õ	
r   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   Ú__static_attributes__r   r   r   r   r      s   † ñò
õ 
r   r   c                   ó~   • \ rS rSrSrS r SS jrS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rSrg)ÚURITestsé:   að  
Abstract tests for L{twisted.web.client.URI}.

Subclass this and L{unittest.TestCase}. Then provide a value for
C{host} and C{uriHost}.

@ivar host: A host specification for use in tests, must be L{bytes}.

@ivar uriHost: The host specification in URI form, must be a L{bytes}. In
    most cases this is identical with C{host}. IPv6 address literals are an
    exception, according to RFC 3986 section 3.2.2, as they need to be
    enclosed in brackets. In this case this variable is different.
c                 ó
  • U R                  U R                  [        5        U R                  U R                  [        5        U R                  U[        5        U R	                  SU5        UR                  SU R                  5      $ )ai  
Replace the string "HOST" in C{template} with this test's host.

Byte strings Python between (and including) versions 3.0 and 3.4
cannot be formatted using C{%} or C{format} so this does a simple
replace.

@type template: L{bytes}
@param template: A string containing "HOST".

@rtype: L{bytes}
@return: A string where "HOST" has been replaced by C{self.host}.
s   HOST)ÚassertIsInstanceÚhostÚbytesÚuriHostÚassertInÚreplace)r   Útemplates     r   ÚmakeURIStringÚURITests.makeURIStringI   sa   € ð 	×Ñ˜dŸi™i¬Ô/Ø×Ñ˜dŸl™l¬EÔ2Ø×Ñ˜h¬Ô.Ø�‰�g˜xÔ(Ø×Ñ ¨¯©Ó6Ð6r   c
                 óà   • U R                  X#XEXgX‰4UR                  UR                  UR                  UR                  UR
                  UR                  UR                  UR                  45        g)a­  
Assert that all of a L{client.URI}'s components match the expected
values.

@param uri: U{client.URI} instance whose attributes will be checked
    for equality.

@type scheme: L{bytes}
@param scheme: URI scheme specifier.

@type netloc: L{bytes}
@param netloc: Network location component.

@type host: L{bytes}
@param host: Host name.

@type port: L{int}
@param port: Port number.

@type path: L{bytes}
@param path: Hierarchical path.

@type params: L{bytes}
@param params: Parameters for last path segment, defaults to C{b''}.

@type query: L{bytes}
@param query: Query string, defaults to C{b''}.

@type fragment: L{bytes}
@param fragment: Fragment identifier, defaults to C{b''}.
N)	r   ÚschemeÚnetlocr$   ÚportÚpathÚparamsÚqueryÚfragment)
r   Úurir-   r.   r$   r/   r0   r1   r2   r3   s
             r   ÚassertURIEqualsÚURITests.assertURIEquals]   s\   € ðD 	×ÑØ˜T¨°uÐGà—
‘
Ø—
‘
Ø—‘Ø—‘Ø—‘Ø—
‘
Ø—	‘	Ø—‘ð	õ	
r   c                 óÀ  • [         R                  R                  U R                  S5      5      nU R	                  SUR
                  5        [         R                  R                  U R                  S5      5      nU R	                  SUR
                  5        [         R                  R                  U R                  S5      5      nU R	                  SUR
                  5        g)zl
L{client.URI.fromBytes} by default assumes port 80 for the I{http}
scheme and 443 for the I{https} scheme.
ó   http://HOSTéP   s   http://HOST:ó   https://HOSTi»  N©r   ÚURIÚ	fromBytesr*   r   r/   ©r   r4   s     r   Útest_parseDefaultPortÚURITests.test_parseDefaultPort�   s�   € ô
 �j‰j×"Ñ" 4×#5Ñ#5°nÓ#EÓFˆØ×Ñ˜˜SŸX™XÔ&ä�j‰j×"Ñ" 4×#5Ñ#5°oÓ#FÓGˆØ×Ñ˜˜SŸX™XÔ&Ü�j‰j×"Ñ" 4×#5Ñ#5°oÓ#FÓGˆØ×Ñ˜˜cŸh™hÕ'r   c                 ó(  • [         R                  R                  U R                  S5      SS9nU R	                  SUR
                  5        [         R                  R                  U R                  S5      SS9nU R	                  SUR
                  5        g)zj
L{client.URI.fromBytes} accepts a C{defaultPort} parameter that
overrides the normal default port logic.
r8   é  )ÚdefaultPortr:   Nr;   r>   s     r   Útest_parseCustomDefaultPortÚ$URITests.test_parseCustomDefaultPortš   s|   € ô
 �j‰j×"Ñ" 4×#5Ñ#5°nÓ#EÐSWÐ"ÐXˆØ×Ñ˜˜sŸx™xÔ(Ü�j‰j×"Ñ"Ø×Ñ˜Ó/¸Tð #ð 
ˆð 	×Ñ˜˜sŸx™xÕ(r   c                 óÞ  • [         R                  R                  U R                  S5      5      nU R	                  SUR
                  5        U R	                  U R                  UR                  5        U R	                  U R                  S-   UR                  5        [         R                  R                  U R                  S5      5      nU R	                  U R                  UR                  5        g)zR
Parsing a I{URI} splits the network location component into I{host} and
I{port}.
s   http://HOST:5144rB   s   :5144s   http://HOST N)	r   r<   r=   r*   r   r/   r$   r&   r.   r>   s     r   Útest_netlocHostPortÚURITests.test_netlocHostPort¦   s¦   € ô
 �j‰j×"Ñ" 4×#5Ñ#5Ð6IÓ#JÓKˆØ×Ñ˜˜sŸx™xÔ(Ø×Ñ˜Ÿ™ C§H¡HÔ-Ø×Ñ˜Ÿ™¨Ñ0°#·*±*Ô=ô �j‰j×"Ñ" 4×#5Ñ#5°oÓ#FÓGˆØ×Ñ˜Ÿ™ s§z¡zÕ2r   c           	      óò   • U R                  S5      n[        R                  R                  U5      nU R	                  USU R
                  U R                  SSS9  U R                  XR                  5       5        g)z
Parse the path from a I{URI}.
s   http://HOST/foo/baró   httpr9   ó   /foo/bar©r-   r.   r$   r/   r0   N©	r*   r   r<   r=   r5   r&   r$   r   ÚtoBytes©r   r4   Úparseds      r   Ú	test_pathÚURITests.test_path´   sm   € ð × Ñ Ð!7Ó8ˆÜ—‘×%Ñ% cÓ*ˆØ×ÑØØØ—<‘<Ø—‘ØØð 	ñ 	
ð 	×Ñ˜Ÿn™nÓ.Õ/r   c           	      óò   • U R                  S5      n[        R                  R                  U5      nU R	                  USU R
                  U R                  SSS9  U R                  XR                  5       5        g)z<
The path of a I{URI} that has no path is the empty string.
r8   rJ   r9   r   rL   NrM   rO   s      r   Útest_noPathÚURITests.test_noPathÄ   sl   € ð × Ñ  Ó0ˆÜ—‘×%Ñ% cÓ*ˆØ×ÑØØØ—<‘<Ø—‘ØØð 	ñ 	
ð 	×Ñ˜Ÿn™nÓ.Õ/r   c           	      ó°   • U R                  S5      nU R                  [        R                  R	                  U5      SU R
                  U R                  SSS9  g)z5
The path of a I{URI} with an empty path is C{b'/'}.
ó   http://HOST/rJ   r9   ó   /rL   N)r*   r5   r   r<   r=   r&   r$   r>   s     r   Útest_emptyPathÚURITests.test_emptyPathÔ   sP   € ð × Ñ  Ó1ˆØ×ÑÜ�J‰J× Ñ  Ó%ØØ—<‘<Ø—‘ØØð 	ò 	
r   c           
      óô   • U R                  S5      n[        R                  R                  U5      nU R	                  USU R
                  U R                  SSSS9  U R                  XR                  5       5        g)z(
Parse I{URI} parameters from a I{URI}.
s   http://HOST/foo/bar;paramrJ   r9   rK   ó   param)r-   r.   r$   r/   r0   r1   NrM   rO   s      r   Ú
test_paramÚURITests.test_paramâ   sp   € ð × Ñ Ð!=Ó>ˆÜ—‘×%Ñ% cÓ*ˆØ×ÑØØØ—<‘<Ø—‘ØØØð 	ñ 	
ð 	×Ñ˜Ÿn™nÓ.Õ/r   c                 óö   • U R                  S5      n[        R                  R                  U5      nU R	                  USU R
                  U R                  SSSSS9  U R                  XR                  5       5        g)	z'
Parse the query string from a I{URI}.
s!   http://HOST/foo/bar;param?a=1&b=2rJ   r9   rK   r\   ó   a=1&b=2)r-   r.   r$   r/   r0   r1   r2   NrM   rO   s      r   Ú
test_queryÚURITests.test_queryó   ss   € ð × Ñ Ð!EÓFˆÜ—‘×%Ñ% cÓ*ˆØ×ÑØØØ—<‘<Ø—‘ØØØØð 	ñ 		
ð 	×Ñ˜Ÿn™nÓ.Õ/r   c                 óø   • U R                  S5      n[        R                  R                  U5      nU R	                  USU R
                  U R                  SSSSSS9	  U R                  XR                  5       5        g	)
z.
Parse the fragment identifier from a I{URI}.
s&   http://HOST/foo/bar;param?a=1&b=2#fragrJ   r9   rK   r\   r`   s   frag)r-   r.   r$   r/   r0   r1   r2   r3   NrM   rO   s      r   Útest_fragmentÚURITests.test_fragment  sv   € ð × Ñ Ð!JÓKˆÜ—‘×%Ñ% cÓ*ˆØ×ÑØØØ—<‘<Ø—‘ØØØØØð 	ñ 
	
ð 	×Ñ˜Ÿn™nÓ.Õ/r   c                 ó˜   • [         R                  R                  U R                  S5      5      nU R	                  SUR
                  5        g)zV
L{client.URI.originForm} produces an absolute I{URI} path including
the I{URI} path.
s   http://HOST/foos   /fooN©r   r<   r=   r*   r   Ú
originFormr>   s     r   Útest_originFormÚURITests.test_originForm  s8   € ô
 �j‰j×"Ñ" 4×#5Ñ#5Ð6HÓ#IÓJˆØ×Ñ˜ #§.¡.Õ1r   c                 ó˜   • [         R                  R                  U R                  S5      5      nU R	                  SUR
                  5        g)z˜
L{client.URI.originForm} produces an absolute I{URI} path including
the I{URI} path, parameters and query string but excludes the fragment
identifier.
s   http://HOST/foo;param?a=1#frags   /foo;param?a=1Nrg   r>   s     r   Útest_originFormComplexÚURITests.test_originFormComplex   s>   € ô �j‰j×"Ñ"Ø×ÑÐ@ÓAó
ˆð 	×ÑÐ*¨C¯N©NÕ;r   c                 ó˜   • [         R                  R                  U R                  S5      5      nU R	                  SUR
                  5        g)zX
L{client.URI.originForm} produces a path of C{b'/'} when the I{URI}
specifies no path.
r8   rX   Nrg   r>   s     r   Útest_originFormNoPathÚURITests.test_originFormNoPath+  s7   € ô
 �j‰j×"Ñ" 4×#5Ñ#5°nÓ#EÓFˆØ×Ñ˜˜sŸ~™~Õ.r   c                 ó˜   • [         R                  R                  U R                  S5      5      nU R	                  SUR
                  5        g)z^
L{client.URI.originForm} produces a path of C{b'/'} when the I{URI}
specifies an empty path.
rW   rX   Nrg   r>   s     r   Útest_originFormEmptyPathÚ!URITests.test_originFormEmptyPath3  s7   € ô
 �j‰j×"Ñ" 4×#5Ñ#5°oÓ#FÓGˆØ×Ñ˜˜sŸ~™~Õ.r   c                 ó\  • U R                  S5      nUR                  S5      n[        U5        [        R                  R                  U5      nU R                  UR                  [        5        U R                  UR                  [        5        U R                  UR                  [        5        g)z³
L{client.URI.fromBytes} parses the scheme, host, and path elements
into L{bytes}, even when passed an URL which has previously been passed
to L{urlparse} as a L{unicode} string.
s   http://HOST/pathÚasciiN)r*   Údecoder   r   r<   r=   r#   r-   r%   r$   r0   )r   Ú	goodInputÚbadInputr4   s       r   Ú test_externalUnicodeInterferenceÚ)URITests.test_externalUnicodeInterference;  s}   € ð ×&Ñ&Ð':Ó;ˆ	Ø×#Ñ# GÓ,ˆÜ�ÔÜ�j‰j×"Ñ" 9Ó-ˆØ×Ñ˜cŸj™j¬%Ô0Ø×Ñ˜cŸh™h¬Ô.Ø×Ñ˜cŸh™h¬Õ.r   r   N)r   r   r   )r   r   r   r   r   r*   r5   r?   rD   rG   rQ   rT   rY   r]   ra   rd   ri   rl   ro   rr   ry   r   r   r   r   r    r    :   s_   † ñò7ð* VYô.
ò`(ò
)ò3ò0ò 0ò 
ò0ò"0ò$0ò&2ò	<ò/ò/õ/r   r    c                   ó    • \ rS rSrSrS=rrSrg)ÚURITestsForHostnameiJ  z6
Tests for L{twisted.web.client.URI} with host names.
s   example.comr   N©r   r   r   r   r   r&   r$   r   r   r   r   r|   r|   J  s   † ñð $Ð#€G‹dr   r|   c                   ó    • \ rS rSrSrS=rrSrg)ÚURITestsForIPv4iR  z?
Tests for L{twisted.web.client.URI} with IPv4 host addresses.
s   192.168.1.67r   Nr}   r   r   r   r   r   R  s   † ñð %Ð$€G‹dr   r   c                   ó&   • \ rS rSrSrSrSrS rSrg)ÚURITestsForIPv6iZ  z§
Tests for L{twisted.web.client.URI} with IPv6 host addresses.

IPv6 addresses must always be surrounded by square braces in URIs. No
attempt is made to test without.
s   fe80::20c:29ff:fea4:c60s   [fe80::20c:29ff:fea4:c60]c                 óò   • [         R                  R                  S5      nU R                  UR                  S5        U R                  UR
                  S5        U R                  UR                  5       S5        g)z–
Brackets around IPv6 addresses are stripped in the host field. The host
field is then exported with brackets in the output of
L{client.URI.toBytes}.
s   http://[::1]:80/index.htmls   ::1s   [::1]:80N)r   r<   r=   r   r$   r.   rN   r>   s     r   Ú"test_hostBracketIPv6AddressLiteralÚ2URITestsForIPv6.test_hostBracketIPv6AddressLiterale  sX   € ô �j‰j×"Ñ"Ð#@ÓAˆà×Ñ˜Ÿ™ 6Ô*Ø×Ñ˜Ÿ™ [Ô1Ø×Ñ˜Ÿ™›Ð(EÕFr   r   N)	r   r   r   r   r   r$   r&   rƒ   r   r   r   r   r�   r�   Z  s   † ñð &€DØ*€Gõ
Gr   r�   N)r   Úurllib.parser   Útwisted.trialr   Útwisted.webr   ÚTestCaser   r    r|   r   r�   r   r   r   Ú<module>r‰      ss   ðñõ
 "å "Ý ô(
�8×$Ñ$ô (
÷VM/ñ M/ô`$˜( H×$5Ñ$5ô $ô%�h × 1Ñ 1ô %ôG�h × 1Ñ 1õ Gr   