Skip to content

Commit

Permalink
Merge pull request #478 from jacadzaca/refactor_test_unicode_params
Browse files Browse the repository at this point in the history
refactor test_unicode_param
  • Loading branch information
niccokunzmann committed Oct 29, 2022
2 parents 2c93383 + 8966432 commit 0607510
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/icalendar/tests/events/event_with_unicode_organizer.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN:VEVENT
ORGANIZER;CN="Джон Доу":mailto:john.doe@example.org
END:VEVENT
13 changes: 8 additions & 5 deletions src/icalendar/tests/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ def test_event_from_ical_respects_unicode(test_input, field, expected_value, eve
event = events[test_input]
assert event[field].to_ical().decode('utf-8') == expected_value

def test_events_parameter_unicoded(events):
'''chokes on umlauts in ORGANIZER
https://github.com/collective/icalendar/issues/101
'''
assert events.issue_101_icalendar_chokes_on_umlauts_in_organizer['ORGANIZER'].params['CN'] == 'acme, ädmin'
@pytest.mark.parametrize('test_input, expected_output', [
# chokes on umlauts in ORGANIZER
# https://github.com/collective/icalendar/issues/101
('issue_101_icalendar_chokes_on_umlauts_in_organizer', 'acme, ädmin'),
('event_with_unicode_organizer', 'Джон Доу'),
])
def test_events_parameter_unicoded(events, test_input, expected_output):
assert events[test_input]['ORGANIZER'].params['CN'] == expected_output

def test_parses_event_with_non_ascii_tzid_issue_237(calendars, in_timezone):
"""Issue #237 - Fail to parse timezone with non-ascii TZID
Expand Down
1 change: 1 addition & 0 deletions src/icalendar/tests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def test_issue_157_removes_trailing_semicolon(events):
# PERIOD should be put back into shape
'issue_156_RDATE_with_PERIOD',
'issue_156_RDATE_with_PERIOD_list',
'event_with_unicode_organizer',
])
def test_event_to_ical_is_inverse_of_from_ical(events, event_name):
"""Make sure that an event's ICS is equal to the ICS it was made from."""
Expand Down
15 changes: 0 additions & 15 deletions src/icalendar/tests/test_property_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,6 @@ def test_property_params(self):
ical2 = Calendar.from_ical(ical_str)
self.assertEqual(ical2.get('ORGANIZER').params.get('CN'), 'Doe, John')

def test_unicode_param(self):
cal_address = vCalAddress('mailto:john.doe@example.org')
cal_address.params["CN"] = "Джон Доу"
vevent = Event()
vevent['ORGANIZER'] = cal_address
self.assertEqual(
vevent.to_ical().decode('utf-8'),
'BEGIN:VEVENT\r\n'
'ORGANIZER;CN="Джон Доу":mailto:john.doe@example.org\r\n'
'END:VEVENT\r\n'
)

self.assertEqual(vevent['ORGANIZER'].params['CN'],
'Джон Доу')

def test_escaping(self):
# verify that escaped non safe chars are decoded correctly
NON_SAFE_CHARS = ',\\;:'
Expand Down

0 comments on commit 0607510

Please sign in to comment.