o
    Ïó·iÞ  ã                   @   sX   d dl mZ d dlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
 G dd	„ d	eƒZd
S )é    )Úunicode_literals)Úcasté   )Ú_urlé   )ÚHyperlinkTestCase)Úregister_schemeÚURLÚ
DecodedURLc                   @   sT   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚTestSchemeRegistrationc                 C   s   t tjƒ| _ttjƒ| _d S ©N)Údictr   ÚSCHEME_PORT_MAPÚ_orig_scheme_port_mapÚsetÚNO_NETLOC_SCHEMESÚ_orig_no_netloc_schemes©Úself© r   úmC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\hyperlink/test/test_scheme_registration.pyÚsetUp   s   zTestSchemeRegistration.setUpc                 C   s   | j t_| jt_d S r   )r   r   r   r   r   r   r   r   r   ÚtearDown   s   zTestSchemeRegistration.tearDownc                 C   s¸   t dddd� t d¡}|jdksJ ‚|jdksJ ‚|jdu s!J ‚t d¡}|jdd�}| ¡ dks4J ‚t d	¡}| ¡ dksAJ ‚t d
dd� td
d�}|jdd�}| ¡ dksZJ ‚d S )NZdeltronTiÖ  ©Úuses_netlocÚdefault_portzdeltron://example.comzdeltron:zexample.com)Úhostzdeltron://example.com:3030Znonetroni×  ©r   ©Úschemeznonetron://example.com)r   r	   Ú	from_textr   Úportr   ÚreplaceÚto_text)r   Úu1Úu2Úu3Úu4r   r   r   Útest_register_scheme_basic   s   



z1TestSchemeRegistration.test_register_scheme_basicc                 C   s6   t ddd� tdd�}|jdd�}| ¡ dksJ ‚d S )NZ	noloctronF©r   r   )ZexampleÚpath)r*   znoloctron:example/path)r   r	   r"   r#   )r   r'   r   r   r   Útest_register_no_netloc_scheme-   s   
z5TestSchemeRegistration.test_register_no_netloc_schemec                 C   s>   |   t¡� tdddd� W d   ƒ d S 1 sw   Y  d S )NZbadnetloclessFé   r   )ÚassertRaisesÚ
ValueErrorr   r   r   r   r   Ú!test_register_no_netloc_with_port4   s   "ÿz8TestSchemeRegistration.test_register_no_netloc_with_portc                 C   s€   |   t¡� tdttd ƒd� W d   ƒ n1 sw   Y  |   t¡� tdtttƒ ƒd� W d   ƒ d S 1 s9w   Y  d S )NZ	badnetlocr)   ©r-   r.   r   r   ÚboolÚobjectr   r   r   r   Útest_invalid_uses_netloc9   s   ÿ"ÿz/TestSchemeRegistration.test_invalid_uses_netlocc                 C   óD   |   t¡� tdtttƒ ƒd� W d   ƒ d S 1 sw   Y  d S )NZlolr)   r0   r   r   r   r   Ú!test_register_invalid_uses_netloc@   ó   "ÿz8TestSchemeRegistration.test_register_invalid_uses_netlocc                 C   r4   )NZnoper   r0   r   r   r   r   Útest_register_invalid_portE   r6   z1TestSchemeRegistration.test_register_invalid_portc                 C   sL   t ddd� t d¡}t d¡}| d¡dgksJ ‚| d¡dgks$J ‚d S )	NZkeepplusF)Zquery_plus_is_spacezkeepplus://example.com/?q=a+bzhttps://example.com/?q=a+bÚqza+bza b)r   r
   r    Úget)r   Zplus_is_not_spaceZplus_is_spacer   r   r   Ú"test_register_no_quote_plus_schemeJ   s   ÿ
z9TestSchemeRegistration.test_register_no_quote_plus_schemeN)Ú__name__Ú
__module__Ú__qualname__r   r   r(   r+   r/   r3   r5   r7   r:   r   r   r   r   r      s    r   N)Ú
__future__r   Útypingr   Ú r   Úcommonr   r   r	   r
   r   r   r   r   r   Ú<module>   s   