refactor: move tests

pull/623/head
Nicco Kunzmann 2024-06-04 21:54:34 +01:00
rodzic 8415bb0bde
commit 34042414e0
4 zmienionych plików z 34 dodań i 37 usunięć

Wyświetl plik

@ -0,0 +1,17 @@
"""Test that composed values are properly converted."""
from icalendar import Event
from datetime import datetime
def test_vDDDLists_timezone(tzp):
"""Test vDDDLists with timezone information."""
vevent = Event()
dt1 = tzp.localize(datetime(2013, 1, 1), 'Europe/Vienna')
dt2 = tzp.localize(datetime(2013, 1, 2), 'Europe/Vienna')
dt3 = tzp.localize(datetime(2013, 1, 3), 'Europe/Vienna')
vevent.add('rdate', [dt1, dt2])
vevent.add('exdate', dt3)
ical = vevent.to_ical()
assert b'RDATE;TZID=Europe/Vienna:20130101T000000,20130102T000000' in ical
assert b'EXDATE;TZID=Europe/Vienna:20130103T000000' in ical

Wyświetl plik

@ -0,0 +1,17 @@
"""Test the mappings from windows to olson tzids"""
from icalendar.timezone.windows_to_olson import WINDOWS_TO_OLSON
import pytest
from icalendar import vDatetime
from datetime import datetime
def test_windows_timezone(tzp):
"""test that an example"""
dt = vDatetime.from_ical('20170507T181920', 'Eastern Standard Time'),
expected = tzp.localize(datetime(2017, 5, 7, 18, 19, 20), 'America/New_York')
@pytest.mark.parametrize("olson_id", WINDOWS_TO_OLSON.values())
def test_olson_names(tzp, olson_id):
"""test if all mappings actually map to valid tzids"""
assert tzp.timezone(olson_id) is not None

Wyświetl plik

@ -7,7 +7,6 @@ import unittest
from icalendar.prop import vDatetime, vDDDTypes
from icalendar.timezone.windows_to_olson import WINDOWS_TO_OLSON
import pytest
import pytz
from copy import deepcopy
from dateutil import tz
@ -543,39 +542,3 @@ def test_vDDDTypes_equivalance(map, v_type, other):
def test_inequality_with_different_types(v_type):
assert v_type != 42
assert v_type != 'test'
class TestPropertyValues(unittest.TestCase):
def test_vDDDLists_timezone(self):
"""Test vDDDLists with timezone information.
"""
from .. import Event
vevent = Event()
at = pytz.timezone('Europe/Vienna')
dt1 = at.localize(datetime(2013, 1, 1))
dt2 = at.localize(datetime(2013, 1, 2))
dt3 = at.localize(datetime(2013, 1, 3))
vevent.add('rdate', [dt1, dt2])
vevent.add('exdate', dt3)
ical = vevent.to_ical()
self.assertTrue(
b'RDATE;TZID=Europe/Vienna:20130101T000000,20130102T000000' in ical
)
self.assertTrue(b'EXDATE;TZID=Europe/Vienna:20130103T000000' in ical)
class TestWindowsOlsonMapping(unittest.TestCase):
"""Test the mappings from windows to olson tzids"""
def test_windows_timezone(self):
"""test that an example"""
self.assertEqual(
vDatetime.from_ical('20170507T181920', 'Eastern Standard Time'),
pytz.timezone('America/New_York').localize(datetime(2017, 5, 7, 18, 19, 20))
)
def test_all(self):
"""test if all mappings actually map to valid pytz tzids"""
for olson in WINDOWS_TO_OLSON.values():
pytz.timezone(olson)