Skip to content

Commit

Permalink
Correct bug in TaskwarriorSide.items_are_identical, move tw<>caldav t…
Browse files Browse the repository at this point in the history
…ests to new test file
  • Loading branch information
bergercookie committed Aug 18, 2024
1 parent 0955533 commit 855c229
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 132 deletions.
4 changes: 2 additions & 2 deletions syncall/caldav/caldav_side.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from syncall.app_utils import error_and_exit
from syncall.caldav.caldav_utils import calendar_todos, icalendar_component, map_ics_to_item
from syncall.sync_side import SyncSide
from syncall.sync_side import ItemType, SyncSide


class CaldavSide(SyncSide):
Expand Down Expand Up @@ -137,7 +137,7 @@ def set_(key: str, val: Any): # noqa: ANN401

todo.save()

def add_item(self, item):
def add_item(self, item) -> ItemType:
todo = self._calendar.add_todo(
summary=item.get("summary"),
priority=item.get("priority"),
Expand Down
3 changes: 3 additions & 0 deletions syncall/taskwarrior/taskwarrior_side.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ def items_are_identical(
item2: dict,
ignore_keys: Sequence[str] = [],
) -> bool:
item1 = item1.copy()
item2 = item2.copy()

keys = [
k
for k in [
Expand Down
4 changes: 3 additions & 1 deletion syncall/tw_caldav_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from syncall.caldav.caldav_utils import parse_caldav_item_desc

CALDAV_TASK_CANCELLED_UDA = "caldav_completion_status"
CALDAV_TASK_CANCELLED_UDA = "syncall_caldav_task_cancelled"
SYNCALL_TW_WAITING = "x-syncall-tw-waiting"
SYNCALL_TW_UUID = "x-syncall-tw-uuid"

Expand Down Expand Up @@ -91,6 +91,8 @@ def convert_tw_to_caldav(tw_item: Item) -> Item:
# Priority
if "priority" in tw_item:
caldav_item["priority"] = aliases_tw_caldav_priority[tw_item["priority"].lower()]
else:
caldav_item["priority"] = ""

# Timestamps
if "entry" in tw_item:
Expand Down
40 changes: 0 additions & 40 deletions tests/test_data/sample_items.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,6 @@ tw_item_w_due:
annotations:
- This is the annotation text
- This is the other annotation text
caldav_item_expected:
description: |-
This is the annotation text
This is the other annotation text
summary: Kalimera!
last-modified: 2019-03-05 00:03:09
status: 'needs-action'
categories: ['remindme']
x-syncall-tw-uuid: '00208973-20da-4988-ae3e-58ef3650c363'
caldav_item_w_date_expected:
description: |-
This is the annotation text
This is the other annotation text
due: 2019-03-09 00:00:00
start: 2019-03-08 23:00:00
summary: Kalimera!
last-modified: 2019-03-05 00:03:09
status: 'needs-action'
categories: ['remindme']
x-syncall-tw-uuid: '00208973-20da-4988-ae3e-58ef3650c363'
gcal_item_expected:
description: 'IMPORTED FROM TASKWARRIOR
Expand Down Expand Up @@ -92,14 +72,6 @@ gcal_item_w_date:
summary: gcal original event
transparency: transparent
updated: '2019-03-16T16:01:32.486Z'
caldav_item_w_date:
priority: ''
due: 2019-03-09 00:00:00
id: 2s3acrn586e4ed7eff49ja91oh
start: 2019-03-10 23:00:00
status: 'needs-action'
summary: 'gcal original event'
last-modified: 2019-03-16 16:01:32.486
tw_item_w_date_expected:
syncallduration: "PT86400S"
annotations: []
Expand Down Expand Up @@ -139,18 +111,6 @@ gcal_item:
status: confirmed
summary: another summary goes here
updated: '2019-03-08T00:29:06.602Z'
caldav_item:
description: |-
kalimera
kalinuxta kai kali vradia
due: 2019-03-04 05:00:00
id: 52ggba92l9ph4d0ghabi3ohdh7
start: 2019-03-04 04:00:00
status: 'needs-action'
summary: another summary goes here
last-modified: 2019-03-08 00:29:06.602
priority: ''
x-syncall-tw-uuid: '00208973-20da-4988-ae3e-58ef3650c363'
tw_item_expected:
syncallduration: "PT3600S"
annotations:
Expand Down
Loading

0 comments on commit 855c229

Please sign in to comment.