o
    .j	                     @   s   d Z ddlZG dd dZdS )aj  Test for Issue #321 - AssertionError with VTIMEZONE containing only DAYLIGHT.

When a VTIMEZONE component contains only a DAYLIGHT subcomponent (no STANDARD),
converting it to a pytz timezone with lookup_tzid=False would fail with an
AssertionError.

The issue occurs because the code assumes it can find a non-DST (STANDARD)
transition to calculate the dst_offset, but when only DAYLIGHT exists, this
assumption fails.

Original issue: https://github.com/collective/icalendar/issues/321
Original PR with test case: https://github.com/collective/icalendar/pull/379
Test case by: @niccokunzmann
Fix by: @SashankBhamidi
    Nc                   @   s.   e Zd ZdZejdd Zdd Zdd ZdS )	TestIssue321DstOffsetz7Test VTIMEZONE conversion with only DAYLIGHT component.c                 C   s   |j S )z6Load calendar with VTIMEZONE containing only DAYLIGHT.)(issue_321_assert_dst_offset_is_not_false)self	calendars r   ^/home/thesage/.local/lib/python3.10/site-packages/icalendar/tests/test_issue_321_dst_offset.pycalendar_with_only_daylight   s   z1TestIssue321DstOffset.calendar_with_only_daylightc                 C   sF   t | d }|jdksJ |d dksJ | }|dus!J dS )a
  Test that VTIMEZONE with only DAYLIGHT can be converted to timezone.

        This tests the specific case from issue #321 where a calendar generated
        by khal had a VTIMEZONE with only DAYLIGHT, causing an AssertionError
        when calling to_tz().
           	VTIMEZONETZIDEurope/BerlinN)listwalknameto_tz)r   r   timezonetzr   r   r   :test_vtimezone_with_only_daylight_does_not_raise_assertion   s
   	zPTestIssue321DstOffset.test_vtimezone_with_only_daylight_does_not_raise_assertionc                 C   s\   t jddd ddlm} | }t| d }|j|dd}|d	us%J |jd
ks,J d	S )a  Test forced timezone creation with lookup_tzid=False.

        This is a more stringent test that forces timezone creation from the
        VTIMEZONE definition rather than looking up an existing timezone.
        This was the specific case that triggered the AssertionError.
        pytzzThis test requires pytz)reasonr   )PYTZr	   F)tzplookup_tzidNr   )pytestimportorskipicalendar.timezone.pytzr   r   r   r   zone)r   r   r   pytz_providerr   r   r   r   r   1test_vtimezone_with_only_daylight_forced_creation.   s   	zGTestIssue321DstOffset.test_vtimezone_with_only_daylight_forced_creationN)	__name__
__module____qualname____doc__r   fixturer   r   r   r   r   r   r   r      s    
r   )r"   r   r   r   r   r   r   <module>   s    