U
    ¤�©j&  ã                   @   s,  d Z ddlZddlmZ ddlZddlmZ ddlmZm	Z	m
Z
 erTddlmZmZ ej ddd	„ d
d	„ g¡Zedd„ ƒZedd„ ƒZedd„ ƒZej dddddg¡ej ddd	„ dd	„ dd	„ g¡dd„ ƒƒZej ddddejg¡d d!„ ƒZej d"d#d$d%d&d'g¡Zed(d)„ ƒZed*d+„ ƒZd,d-„ ZdS ).zNThis implemensts RFC 6868.

There are only some changes to parameters needed.
é    N)ÚTYPE_CHECKING)ÚCalendar)ÚdquoteÚrfc_6868_escapeÚrfc_6868_unescape)ÚvCalAddressÚvTextÚ	duplicatec                 C   s   | S ©N© ©Úxr   r   úA/tmp/pip-unpacked-wheel-g40nyxg1/icalendar/tests/test_rfc_6868.pyÚ<lambda>   ó    r   c                 C   s   t  |  ¡ ¡S r
   )r   Ú	from_icalÚto_ical)Úcalr   r   r   r      r   c                 C   s*   || j ƒ}|jd d }|jdks&t‚dS )zCheck the example from the RFC.r   ÚattendeezGeorge Herman "Babe" RuthN)Úrfc_6868ÚeventsÚnameÚAssertionError)Ú	calendarsr	   r   r   r   r   r   Útest_rfc_6868_example   s    
r   c                 C   s(   || j ƒ}|d jd }|dks$t‚dS )z.Check that all examples get decoded correctly.úX-PARAMÚALLz^"
N©r   Úparamsr   ©r   r	   r   Úparamr   r   r   Útest_all_parameters   s    
r!   c                 C   s(   || j ƒ}|d jd }|dks$t‚dS )z if a ^ (U+005E) character is followed by any character other than
      the ones above, parsers MUST leave both the ^ and the following
      character in placer   ÚUNKNOWNz^a^ ^asdNr   r   r   r   r   Útest_unknown_character&   s    
r#   )ÚtextÚexpected)ú^ar&   )ú^^ú^)z^'ú")z^^a^bz^a^bÚmodifyc                 C   s   | S r
   r   r   r   r   r   r   ;   r   c                 C   s   | d S )Né
   r   r   r   r   r   r   ;   r   c                 C   s   d| › d�S )NÚasdzaaA^AAr   r   r   r   r   r   ;   r   c                 C   s    t || ƒƒ}|||ƒkst‚dS )zCheck unescaping.N)r   r   )r$   r%   r*   Úresultr   r   r   Útest_unescape0   s    r.   ÚnewlineÚ
z
úc                 C   s"   |  td| ¡ tdƒ| kst‚dS )zUnescape the newline.Úlinesepú^nN)ÚsetattrÚosr   r   )r/   Zmonkeypatchr   r   r   Útest_unescape_newlineC   s    r6   ztext, expected)Ú r7   )r(   r'   )r3   z^^n)zThis text
 has several
 linesz!This text^n has^n several^n lines)zCall me "Harry".zCall me ^'Harry^'.c                 C   s:   t | ƒ}||ks"t|›d|›�ƒ‚t t|ƒƒ|ks6t‚dS )z=Check that we can escape the content with special characters.z == N)r   r   r   )r$   r%   Úescapedr   r   r   Útest_escape_rfc_6868T   s    r9   c                 C   sP   t ƒ }| dd¡ |d }| |jd< | ¡  ¡ }t|ƒ dt|ƒ |ksLt‚d S )NzX-Paramr,   r   ZRFC6868zX-PARAM;RFC6868=)r   Úaddr   r   ÚdecodeÚprintr   r   )r$   r%   r   r    Zicalr   r   r   Útest_escaping_parameters\   s    
r=   c                 C   s8   | j }t | ¡ ¡}||ks t‚| ¡ | ¡ ks4t‚dS )z0The example file should yield its content again.N)r   r   r   r   r   )r   r   Zagainr   r   r   Útest_encode_example_againg   s    r>   )Ú__doc__r5   Útypingr   ZpytestZ	icalendarr   Zicalendar.parserr   r   r   r   r   ÚmarkZparametrizeZparam_duplicater   r!   r#   r.   r2   r6   Zparam_valuesr9   r=   r>   r   r   r   r   Ú<module>   s^   þ


	ûþ
 ÿ ÿ
û	


