From b67665f94082896ece357ab4d5945a1fef0b4ba9 Mon Sep 17 00:00:00 2001 From: "Jeroen van Meeuwen (Kolab Systems)" Date: Tue, 17 Jul 2012 21:27:57 +0100 Subject: [PATCH] Make sure parameters to certain properties propagate when generating the ical output --- src/icalendar/cal.py | 5 ++++- src/icalendar/tests/test-property_params.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/icalendar/tests/test-property_params.py diff --git a/src/icalendar/cal.py b/src/icalendar/cal.py index 6ddf457..461f9d8 100644 --- a/src/icalendar/cal.py +++ b/src/icalendar/cal.py @@ -259,7 +259,10 @@ class Component(CaselessDict): if cond: klass = types_factory.for_property(name) - return klass(value) + _klass = klass(value) + if hasattr(value, 'params') and len(value.params.keys()) > 0: + _klass.params = value.params + return _klass return value diff --git a/src/icalendar/tests/test-property_params.py b/src/icalendar/tests/test-property_params.py new file mode 100644 index 0000000..b77865b --- /dev/null +++ b/src/icalendar/tests/test-property_params.py @@ -0,0 +1,17 @@ +import icalendar +import unittest + +class TestPropertyParams(unittest.TestCase): + + def test_property_params(self): + cal_address = icalendar.vCalAddress('mailto:john.doe@example.org') + cal_address.params["CN"] = "Doe, John" + ical = icalendar.Calendar() + ical.add('organizer', cal_address) + + ical_str = icalendar.Calendar.to_ical(ical) + exp_str = """BEGIN:VCALENDAR\r\nORGANIZER;CN="Doe, John":mailto:john.doe@example.org\r\nEND:VCALENDAR\r\n""" + + self.assertEqual(ical_str, exp_str) + + raise Exception