kopia lustrzana https://github.com/collective/icalendar
rodzic
25b3dfcc71
commit
7ed3bf758c
|
|
@ -165,6 +165,9 @@ extend-safe-fixes = [
|
|||
]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"src/icalendar/tests/test_timezoned.py" = [
|
||||
"SLF001", # private member
|
||||
]
|
||||
"src/icalendar/tests/*" = [
|
||||
"B011", # Do not assert False (python -O removes these calls), raise AssertionError()
|
||||
"DTZ001", # datetime.datetime() called without a tzinfo argument
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from icalendar.error import IncompleteComponent
|
|||
|
||||
from .alarm import Alarm
|
||||
from .calendar import Calendar
|
||||
from .component import Component
|
||||
from .component import Component, types_factory
|
||||
from .event import Event
|
||||
from .examples import get_example
|
||||
from .free_busy import FreeBusy
|
||||
|
|
@ -29,4 +29,5 @@ __all__ = [
|
|||
"TimezoneStandard",
|
||||
"Todo",
|
||||
"get_example",
|
||||
"types_factory",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ from __future__ import annotations
|
|||
|
||||
from datetime import datetime
|
||||
|
||||
from icalendar import ComponentFactory
|
||||
from icalendar.attr import single_utc_property
|
||||
from icalendar.cal.component_factory import ComponentFactory
|
||||
from icalendar.caselessdict import CaselessDict
|
||||
from icalendar.parser import Contentline, Contentlines, Parameters, q_join, q_split
|
||||
from icalendar.parser_tools import DEFAULT_ENCODING
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from pathlib import Path
|
|||
|
||||
def get_example(component_directory: str, example_name: str) -> bytes:
|
||||
"""Return an example and raise an error if it is absent."""
|
||||
here = Path(__file__).parent
|
||||
here = Path(__file__).parent.parent
|
||||
examples = here / "tests" / component_directory
|
||||
if not example_name.endswith(".ics"):
|
||||
example_name = example_name + ".ics"
|
||||
|
|
|
|||
|
|
@ -79,24 +79,24 @@ PROPER_OUTPUT = f""" Organizer: organizer <organizer@test.test>
|
|||
End : {secondend}
|
||||
Duration : 0:30:00
|
||||
Location : New Amsterdam, 1010 Test Street
|
||||
Comment :
|
||||
Comment :
|
||||
Description:
|
||||
Test Description
|
||||
This one is multiline
|
||||
|
||||
Organizer:
|
||||
Organizer:
|
||||
Attendees:
|
||||
|
||||
Summary : TEST
|
||||
Starts : Wed May 11 00:00:00 2022
|
||||
End : Mon May 16 00:00:00 2022
|
||||
Duration : 5 days, 0:00:00
|
||||
Location :
|
||||
Comment :
|
||||
Location :
|
||||
Comment :
|
||||
Description:
|
||||
|
||||
|
||||
|
||||
"""
|
||||
""" # noqa: W291, W293
|
||||
|
||||
|
||||
class CLIToolTest(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
"""Create a new method for the Calendar class.
|
||||
|
||||
See https://github.com/collective/icalendar/issues/596
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from icalendar import __version__
|
||||
from icalendar.cal.calendar import Calendar
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("name", "default_value"),
|
||||
[
|
||||
("name", None),
|
||||
("description", None),
|
||||
("prodid", f"-//collective//icalendar//{__version__}//EN"),
|
||||
("version", "2.0"),
|
||||
("calscale", None),
|
||||
("method", None),
|
||||
("color", None),
|
||||
],
|
||||
)
|
||||
def test_new_calendar_has_some_values(name, default_value):
|
||||
"""When we create a new calendar, we want to have these values as default."""
|
||||
c = Calendar.new()
|
||||
assert c.get(name) == default_value
|
||||
assert default_value is None or name in c
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("name", "value"),
|
||||
[
|
||||
("name", "foo"),
|
||||
("description", "bar"),
|
||||
("prodid", "my-product"),
|
||||
("version", "2.1"),
|
||||
("calscale", "GREGORIAN"),
|
||||
("method", "PUBLISH"),
|
||||
("color", "#ff0000"),
|
||||
],
|
||||
)
|
||||
def test_override_default_values(name, value):
|
||||
c = Calendar.new(**{name: value})
|
||||
assert c.get(name) == value
|
||||
|
||||
|
||||
def test_default_getters():
|
||||
c = Calendar.new()
|
||||
assert c.calendar_name is None
|
||||
assert c.description is None
|
||||
assert c.version == "2.0"
|
||||
assert c.prodid == f"-//collective//icalendar//{__version__}//EN"
|
||||
assert c.calscale == "GREGORIAN"
|
||||
assert c.method == ""
|
||||
assert c.color == ""
|
||||
assert c.categories == []
|
||||
assert c.subcomponents == []
|
||||
|
||||
|
||||
def test_categories():
|
||||
c = Calendar.new(categories=["foo", "bar"])
|
||||
assert c.categories == ["foo", "bar"]
|
||||
|
|
@ -2,7 +2,7 @@ import datetime
|
|||
import os
|
||||
|
||||
import icalendar
|
||||
import icalendar.cal.calendar
|
||||
import icalendar.cal
|
||||
|
||||
|
||||
def test_value_type_is_not_mapped():
|
||||
|
|
@ -16,8 +16,8 @@ def test_value_type_is_mapped(x_sometime):
|
|||
|
||||
|
||||
def test_create_from_ical(x_sometime):
|
||||
directory = os.path.dirname(__file__)
|
||||
ics = open(os.path.join(directory, "calendars", "time.ics"), "rb")
|
||||
directory = os.path.dirname(__file__) # noqa: PTH120
|
||||
ics = open(os.path.join(directory, "calendars", "time.ics"), "rb") # noqa: PTH118, PTH123, SIM115
|
||||
cal = icalendar.cal.calendar.Calendar.from_ical(ics.read())
|
||||
ics.close()
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import icalendar
|
|||
import icalendar.cal.calendar
|
||||
import icalendar.cal.event
|
||||
import icalendar.cal.timezone
|
||||
import icalendar.cal.TimezoneDaylight
|
||||
import icalendar.cal.TimezoneStandard
|
||||
from icalendar.prop import tzid_from_dt
|
||||
|
||||
|
||||
|
|
@ -49,14 +47,14 @@ def test_create_to_ical(tzp):
|
|||
tzc.add("tzid", "Europe/Vienna")
|
||||
tzc.add("x-lic-location", "Europe/Vienna")
|
||||
|
||||
tzs = icalendar.cal.TimezoneStandard.TimezoneStandard()
|
||||
tzs = icalendar.cal.timezone.TimezoneStandard()
|
||||
tzs.add("tzname", "CET")
|
||||
tzs.add("dtstart", datetime.datetime(1970, 10, 25, 3, 0, 0))
|
||||
tzs.add("rrule", {"freq": "yearly", "bymonth": 10, "byday": "-1su"})
|
||||
tzs.add("TZOFFSETFROM", datetime.timedelta(hours=2))
|
||||
tzs.add("TZOFFSETTO", datetime.timedelta(hours=1))
|
||||
|
||||
tzd = icalendar.cal.TimezoneDaylight.TimezoneDaylight()
|
||||
tzd = icalendar.cal.timezone.TimezoneDaylight()
|
||||
tzd.add("tzname", "CEST")
|
||||
tzd.add("dtstart", datetime.datetime(1970, 3, 29, 2, 0, 0))
|
||||
tzs.add("rrule", {"freq": "yearly", "bymonth": 3, "byday": "-1su"})
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue