diff --git a/syncall/taskwarrior/taskw_duration.py b/syncall/taskwarrior/taskw_duration.py index f987de5..5ba9277 100644 --- a/syncall/taskwarrior/taskw_duration.py +++ b/syncall/taskwarrior/taskw_duration.py @@ -110,9 +110,9 @@ def parse_iso8601_duration(string: str) -> timedelta: def taskw_duration_serialize(value: timedelta) -> str: """ - >>> duration_serialize(timedelta(days=300)) + >>> taskw_duration_serialize(timedelta(days=300)) 'PT25920000S' - >>> duration_serialize(timedelta(minutes=3)) + >>> taskw_duration_serialize(timedelta(minutes=3)) 'PT180S' """ # TODO atm (220220529) taskwarrior does not support float notation for its fields (i.e., diff --git a/tests/test_data/sample_items.yaml b/tests/test_data/sample_items.yaml index 57f7079..efc2b36 100644 --- a/tests/test_data/sample_items.yaml +++ b/tests/test_data/sample_items.yaml @@ -10,7 +10,7 @@ tw_item: id: 276 modified: 2019-03-05 00:03:09 status: pending - twgcalsyncduration: "PT1200S" + syncallduration: "PT1200S" tags: - remindme urgency: 0 @@ -104,7 +104,6 @@ gcal_item_w_date: updated: '2019-03-16T16:01:32.486Z' caldav_item_w_date: priority: '' - created: 2019-03-16 16:01:32.00 due: 2019-03-09 00:00:00 id: 2s3acrn586e4ed7eff49ja91oh start: 2019-03-10 23:00:00 @@ -112,14 +111,13 @@ caldav_item_w_date: summary: 'gcal original event' last-modified: 2019-03-16 16:01:32.486 tw_item_w_date_expected: - twgcalsyncduration: "PT86400S" + syncallduration: "PT86400S" annotations: [] description: gcal original event due: 2019-03-09 00:00:00 status: pending modified: 2019-03-16 16:01:32.486000 gcal_item: - created: '2019-03-08T00:29:06.000Z' creator: {email: kalimera@gmail.com} description: ' @@ -152,7 +150,6 @@ gcal_item: summary: another summary goes here updated: '2019-03-08T00:29:06.602Z' caldav_item: - created: 2019-03-08 00:29:06.000 description: ' The same old description @@ -172,7 +169,7 @@ caldav_item: last-modified: 2019-03-08 00:29:06.602 priority: '' tw_item_expected: - twgcalsyncduration: "PT3600S" + syncallduration: "PT3600S" annotations: - kalimera - kalinuxta kai kali vradia diff --git a/tests/test_tw_caldav_conversions.py b/tests/test_tw_caldav_conversions.py index 9172c7b..dfcf731 100755 --- a/tests/test_tw_caldav_conversions.py +++ b/tests/test_tw_caldav_conversions.py @@ -1,4 +1,5 @@ from pathlib import Path +from typing import Dict import yaml @@ -24,7 +25,7 @@ def load_sample_items(self): self.caldav_item = conts["caldav_item"] self.tw_item_expected = conts["tw_item_expected"] - self.tw_item = conts["tw_item"] + self.tw_item: Dict[str, Any] = conts["tw_item"] self.tw_item_w_due = conts["tw_item_w_due"] self.caldav_item_expected = conts["caldav_item_expected"] self.caldav_item_w_date_expected = conts["caldav_item_w_date_expected"] @@ -33,20 +34,28 @@ def load_sample_items(self): self.tw_item_w_date_expected = conts["tw_item_w_date_expected"] # we don't care about this field yet. - self.tw_item.pop("twgcalsyncduration") - self.tw_item_expected.pop("twgcalsyncduration") - self.tw_item_w_date_expected.pop("twgcalsyncduration") + self.tw_item.pop("syncallduration") + self.tw_item_expected.pop("syncallduration") + + self.tw_item_w_date_expected.pop("syncallduration") + if "entry" in self.tw_item_w_date_expected: + self.tw_item_w_date_expected.pop("entry") + if "created" in self.tw_item_w_date_expected: + self.tw_item_w_date_expected.pop("created") def test_tw_caldav_basic_convert(self): """Basic TW -> Caldav conversion.""" self.load_sample_items() + tw_item = self.tw_item caldav_item_out = convert_tw_to_caldav(self.tw_item) + caldav_item_out.pop("created", "") self.assertDictEqual(caldav_item_out, self.caldav_item_expected) def test_tw_caldav_w_due_convert(self): """Basic TW (with 'due' subfield) -> Caldav conversion.""" self.load_sample_items() caldav_item_out = convert_tw_to_caldav(self.tw_item_w_due) + caldav_item_out.pop("created", "") self.assertDictEqual(caldav_item_out, self.caldav_item_w_date_expected) def test_caldav_tw_basic_convert(self): @@ -68,11 +77,12 @@ def test_tw_caldav_n_back(self): # UGLY - Rewrite how we do testing for caldav<>tw and gcal<>tw intermediate_caldav = convert_tw_to_caldav(self.tw_item) intermediate_caldav["priority"] = "" + intermediate_caldav.pop("created", "") tw_item_out = convert_caldav_to_tw(intermediate_caldav) self.assertSetEqual( set(self.tw_item) ^ set(tw_item_out), - set({"id", "urgency", "entry"}), + set({"id", "urgency", "entry", "entry"}), ) intersection = set(self.tw_item) & set(tw_item_out) @@ -93,7 +103,6 @@ def test_caldav_tw_n_back(self): set(self.caldav_item) ^ set(caldav_item_out), set( { - "created", "id", } ),