diff --git a/src/icalendar/tests/events/issue_82_expected_output.ics b/src/icalendar/tests/events/issue_82_expected_output.ics new file mode 100644 index 0000000..61872f6 --- /dev/null +++ b/src/icalendar/tests/events/issue_82_expected_output.ics @@ -0,0 +1,3 @@ +BEGIN:VEVENT +ATTACH;ENCODING=BASE64;FMTTYPE=text/plain;VALUE=BINARY:dGV4dA== +END:VEVENT diff --git a/src/icalendar/tests/test_fixed_issues.py b/src/icalendar/tests/test_fixed_issues.py index 15bc377..eb2b448 100644 --- a/src/icalendar/tests/test_fixed_issues.py +++ b/src/icalendar/tests/test_fixed_issues.py @@ -129,23 +129,6 @@ END:VEVENT""" b'FREQ=WEEKLY;UNTIL=20070619T225959;INTERVAL=1' ) - def test_issue_82(self): - """Issue #82 - vBinary __repr__ called rather than to_ical from - container types - https://github.com/collective/icalendar/issues/82 - """ - - b = icalendar.vBinary('text') - b.params['FMTTYPE'] = 'text/plain' - self.assertEqual(b.to_ical(), b'dGV4dA==') - e = icalendar.Event() - e.add('ATTACH', b) - self.assertEqual( - e.to_ical(), - b"BEGIN:VEVENT\r\nATTACH;ENCODING=BASE64;FMTTYPE=text/plain;" - b"VALUE=BINARY:dGV4dA==\r\nEND:VEVENT\r\n" - ) - def test_issue_100(self): """Issue #100 - Transformed doctests into unittests, Test fixes and cleanup. diff --git a/src/icalendar/tests/test_parsing.py b/src/icalendar/tests/test_parsing.py new file mode 100644 index 0000000..c75f510 --- /dev/null +++ b/src/icalendar/tests/test_parsing.py @@ -0,0 +1,23 @@ +import base64 + +from icalendar import Event, vBinary + +def test_vBinary_base64_encoded_issue_82(): + '''Issue #82 - vBinary __repr__ called rather than to_ical from + container types + https://github.com/collective/icalendar/issues/82 + ''' + b = vBinary('text') + b.params['FMTTYPE'] = 'text/plain' + assert b.to_ical() == base64.b64encode(b'text') + +def test_creates_event_with_base64_encoded_attachment_issue_82(events): + '''Issue #82 - vBinary __repr__ called rather than to_ical from + container types + https://github.com/collective/icalendar/issues/82 + ''' + b = vBinary('text') + b.params['FMTTYPE'] = 'text/plain' + event = Event() + event.add('ATTACH', b) + assert event.to_ical() == events.issue_82_expected_output.raw_ics