-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: generate VTIMEZONEs and select component types #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SashankBhamidi
wants to merge
3
commits into
main
Choose a base branch
from
feat/generate-vtimezones-final
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| BEGIN:VCALENDAR | ||
| PRODID:-//Google Inc//Google Calendar 70.9054//EN | ||
| VERSION:2.0 | ||
| CALSCALE:GREGORIAN | ||
| METHOD:PUBLISH | ||
| X-WR-CALNAME:Test Calendar | ||
| X-WR-TIMEZONE:America/New_York | ||
| BEGIN:VEVENT | ||
| DTSTART;TZID=America/New_York:20240315T090000 | ||
| DTEND;TZID=America/New_York:20240315T100000 | ||
| DTSTAMP:20240301T120000Z | ||
| UID:test-event-1@google.com | ||
| CREATED:20240301T120000Z | ||
| DESCRIPTION:Test event with timezone reference but no VTIMEZONE component | ||
| LAST-MODIFIED:20240301T120000Z | ||
| SEQUENCE:0 | ||
| STATUS:CONFIRMED | ||
| SUMMARY:Meeting in New York timezone | ||
| TRANSP:OPAQUE | ||
| END:VEVENT | ||
| BEGIN:VEVENT | ||
| DTSTART;TZID=Europe/London:20240320T140000 | ||
| DTEND;TZID=Europe/London:20240320T150000 | ||
| DTSTAMP:20240301T120000Z | ||
| UID:test-event-2@google.com | ||
| CREATED:20240301T120000Z | ||
| DESCRIPTION:Another event with different timezone but no VTIMEZONE | ||
| LAST-MODIFIED:20240301T120000Z | ||
| SEQUENCE:0 | ||
| STATUS:CONFIRMED | ||
| SUMMARY:London meeting | ||
| TRANSP:OPAQUE | ||
| END:VEVENT | ||
| END:VCALENDAR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| BEGIN:VCALENDAR | ||
| PRODID:-//Test//Test//EN | ||
| VERSION:2.0 | ||
| CALSCALE:GREGORIAN | ||
| END:VCALENDAR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| BEGIN:VCALENDAR | ||
| PRODID:-//Test//Test//EN | ||
| VERSION:2.0 | ||
| CALSCALE:GREGORIAN | ||
| BEGIN:VEVENT | ||
| UID:test-single-event@test.com | ||
| SUMMARY:Test Single Event | ||
| DTSTART;TZID=America/Chicago:20240101T120000 | ||
| DTEND;TZID=America/Chicago:20240101T130000 | ||
| DTSTAMP:20240101T000000Z | ||
| END:VEVENT | ||
| END:VCALENDAR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| """Select which components to merge (Issue #182).""" | ||
|
|
||
| import pytest | ||
|
|
||
| from mergecal import CalendarMerger, merge_calendars | ||
|
|
||
|
|
||
| def test_default_components_include_all_types(calendars): | ||
| """All component types are merged by default.""" | ||
| result = merge_calendars(calendars.color_rfc7986.stream) | ||
|
|
||
| assert len(list(result.events)) == 1 | ||
SashankBhamidi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert len(list(result.todos)) == 1 | ||
| assert len(result.journals) == 1 | ||
| assert len(list(result.timezones)) == 0 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "components,num_events,num_todos,num_journals", | ||
| [ | ||
| (["VEVENT"], 1, 0, 0), | ||
| (["VTODO"], 0, 1, 0), | ||
| (["VJOURNAL"], 0, 0, 1), | ||
| ], | ||
| ) | ||
| def test_select_single_component_type( | ||
| calendars, components, num_events, num_todos, num_journals | ||
| ): | ||
| """Only the selected component type is merged.""" | ||
| result = merge_calendars(calendars.color_rfc7986.stream, components=components) | ||
|
|
||
| assert len(list(result.events)) == num_events | ||
| assert len(list(result.todos)) == num_todos | ||
| assert len(result.journals) == num_journals | ||
| assert len(list(result.timezones)) == 0 | ||
|
|
||
|
|
||
| def test_events_include_required_timezones(calendars): | ||
| """ | ||
| VTIMEZONEs required by events are generated even without VTIMEZONE in components. | ||
SashankBhamidi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Timezones follow events automatically; the components list only filters event types. | ||
| """ | ||
| result = merge_calendars( | ||
| calendars.no_vtimezone_google.stream, components=["VEVENT"] | ||
| ) | ||
|
|
||
| assert len(list(result.events)) == 2 | ||
| assert "America/New_York" in {tz.tz_name for tz in result.timezones} | ||
| assert "Europe/London" in {tz.tz_name for tz in result.timezones} | ||
|
|
||
|
|
||
| def test_calendar_merger_components_parameter(calendars): | ||
| """CalendarMerger respects the components parameter.""" | ||
| result = CalendarMerger( | ||
| calendars.color_rfc7986.stream, components=["VEVENT", "VTODO"] | ||
| ).merge() | ||
|
|
||
| assert len(list(result.events)) == 1 | ||
| assert len(list(result.todos)) == 1 | ||
| assert len(result.journals) == 0 | ||
| assert len(list(result.timezones)) == 0 | ||
|
|
||
|
|
||
| def test_empty_components_list(calendars): | ||
| """components=[] produces no events/todos/journals; timezones are unaffected.""" | ||
| result = merge_calendars(calendars.one_event.stream, components=[]) | ||
|
|
||
| assert len(list(result.events)) == 0 | ||
| assert len(list(result.todos)) == 0 | ||
| assert len(result.journals) == 0 | ||
| assert "Europe/Berlin" in {tz.tz_name for tz in result.timezones} | ||
|
|
||
|
|
||
| def test_generate_vtimezone_false_disables_generation(calendars): | ||
| """generate_vtimezone=False suppresses all VTIMEZONE output.""" | ||
| result = merge_calendars( | ||
| calendars.no_vtimezone_google.stream, generate_vtimezone=False | ||
| ) | ||
|
|
||
| assert len(list(result.timezones)) == 0 | ||
|
|
||
|
|
||
| def test_multiple_calendars_component_filtering(calendars): | ||
| """Component filtering applies across all merged calendars.""" | ||
| cals = calendars.one_event.stream + calendars.color_rfc7986.stream | ||
| result = merge_calendars(cals, components=["VEVENT"]) | ||
|
|
||
| assert len(list(result.events)) == 2 | ||
| assert len(list(result.todos)) == 0 | ||
| assert len(result.journals) == 0 | ||
|
|
||
|
|
||
| def test_unknown_components_silently_ignored(calendars): | ||
| """Unknown component names do not crash the merger.""" | ||
| result = CalendarMerger( | ||
| calendars.test_empty_calendar.stream, components=["VEVENT", "UNKNOWN"] | ||
| ).merge() | ||
|
|
||
| assert len(list(result.events)) == 0 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.