o
    .j                     @   st  d Z zddlZddlmZ W n ey   dZY nw ddlZddlZddlmZ ddlZddl	m
Z
mZ ddlmZ ddlmZmZ erRejZe e gZdd	gZn	g Ze gZd	gZejd
eee  ejdedd Zejdejejejgejdedee
dedddddgdd Zdd Zdd Zdd Zdd  Z ejd!ed"d# Z!d$d% Z"dS )&znThis tests the switch to different timezone implementations.

These are mostly located in icalendar.timezone.
    N)PYTZ)datetime)MONTHLYrrule)
_tzicalvtz)ZONEINFOzoneinfopytzr   tz_nametzp_c                 C   s4   | dv rt   || sJ |jj d|  dS )z,Make sure that all timezones are understood.)Factory	localtimez should know N)pytestskipknows_timezone_id	__class____name__)r
   r    r   c/home/thesage/.local/lib/python3.10/site-packages/icalendar/tests/test_pytz_zoneinfo_integration.pytest_timezone_names_are_known    s
   r   funcobjid     
      Tfreqcountdtstartcachec                 C   s   | | dS )z/Check that we can serialize and copy timezones.Nr   )r   tzpr   r   r   r   test_can_pickle_timezone-   s   
r#   c                  C   s6   t tdtddddd} tt| t| ksJ dS )z<When we copy an rrule, we want it to be the same after this.r   r   r   r   Tr   N)r   r   r   strcopydeepcopy)rr   r   r   test_copied_rrule_is_the_same:   s   r(   c                 C   s   |dk|   ks
J dS z-We want the default implementation to switch.r	   N	uses_pytz)r"   tzp_namer   r   r   test_tzp_properly_switches@   s   r-   c                 C   s   |dksJ |   sJ dS r)   r*   )r"   r,   	pytz_onlyr   r   r   test_tzp_is_pytz_onlyE   s   r/   c                 C   sN   |  |j | d}|| du sJ |  |j || du s%J ddS )z>Make sure we do not cache the timezones twice and change them.custom_Pacific/FijizCache is not replaced.N)cache_timezone_componentpacific_fijitimezone)r"   	timezonestzp1r   r   r   test_cache_reuse_timezone_cacheK   s
   
r6   new_tzp_namec                 C   sF   |  |j | d}| | |  |j | d}||us!J dS )zLMake sure we do not reuse the timezones created when we switch the provider.r0   N)r1   r2   r3   use)r"   r4   r7   tz1tz2r   r   r   *test_cache_is_emptied_when_tzp_is_switchedT   s   


r;   c                 C   st   d}t t}| | W d   n1 sw   Y  |jjd }d| d|v s,J d|v s2J d|v s8J dS )z#Check that the provider name is OK.invalid_providerNr   zUnknown provider .r   r	   )r   raises
ValueErrorr8   valueargs)r"   provideremessager   r   r   test_invalid_name_   s   rE   )#__doc__r	   icalendar.timezone.pytzr   ImportErrorr%   pickler   r   dateutil.rruler   r   dateutil.tz.tzr   icalendar.timezone.zoneinfor   r   all_timezonesPYTZ_TIMEZONESTZP_NEW_TZP_NAMEmarkparametrizelistavailable_timezonesr   dumpsr&   r#   r(   r-   r/   r6   r;   rE   r   r   r   r   <module>   sR    
		

