Skip to content

Commit

Permalink
Add URL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
d7415 authored and ephase committed Apr 26, 2021
1 parent 280d606 commit 0540f7b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/event_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ def test_update_simple():
assert normalize_component(event.raw) == normalize_component(event_updated.raw)


def test_add_url():
event = Event.fromString(_get_text('event_dt_simple'), **EVENT_KWARGS)
event.update_url('https://github.com/pimutils/khal')
assert 'URL:https://github.com/pimutils/khal' in event.raw


def test_get_url():
event = Event.fromString(_get_text('event_dt_url'), **EVENT_KWARGS)
assert event.url == "https://github.com/pimutils/khal"


def test_no_end():
"""reading an event with neither DTEND nor DURATION"""
event = Event.fromString(_get_text('event_dt_no_end'), **EVENT_KWARGS)
Expand All @@ -77,6 +88,12 @@ def test_do_not_save_empty_description():
assert 'DESCRIPTION' not in event.raw


def test_do_not_save_empty_url():
event = Event.fromString(_get_text('event_dt_simple'), **EVENT_KWARGS)
event.update_url('')
assert 'URL' not in event.raw


def test_remove_existing_location_if_set_to_empty():
event = Event.fromString(_get_text('event_dt_simple_updated'), **EVENT_KWARGS)
event.update_location('')
Expand All @@ -89,6 +106,12 @@ def test_remove_existing_description_if_set_to_empty():
assert 'DESCRIPTION' not in event.raw


def test_remove_existing_url_if_set_to_empty():
event = Event.fromString(_get_text('event_dt_url'), **EVENT_KWARGS)
event.update_url('')
assert 'URL' not in event.raw


def test_update_remove_categories():
event = Event.fromString(_get_text('event_dt_simple_updated'), **EVENT_KWARGS)
event_nocat = Event.fromString(_get_text('event_dt_simple_nocat'), **EVENT_KWARGS)
Expand Down
12 changes: 12 additions & 0 deletions tests/ics/event_dt_url.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//PIMUTILS.ORG//NONSGML khal / icalendar //EN
BEGIN:VEVENT
SUMMARY:An Event
URL:https://github.com/pimutils/khal
DTSTART;TZID=Europe/Berlin;VALUE=DATE-TIME:20140409T093000
DTEND;TZID=Europe/Berlin;VALUE=DATE-TIME:20140409T103000
DTSTAMP;VALUE=DATE-TIME:20140401T234817Z
UID:V042MJ8B3SJNFXQOJL6P53OFMHJE8Z3VZWOU
END:VEVENT
END:VCALENDAR

0 comments on commit 0540f7b

Please sign in to comment.