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 )zif 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^   


	
  
	


