Skip to content

Commit

Permalink
"todo_completed" is a timestamp, not a bool
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed May 9, 2023
1 parent d56717d commit 934df4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 9 additions & 4 deletions joppy/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,17 @@ def __post_init__(self) -> None:
# Exclude integer and empty string IDs.
if value and isinstance(value, str) and not is_id_valid(value):
raise ValueError("Invalid ID:", value)
elif field_.name.endswith("_time") or field_.name == "todo_due":
setattr(self, field_.name, datetime.fromtimestamp(value / 1000.0))
elif field_.name.endswith("_time") or field_.name in (
"todo_due",
"todo_completed",
):
casted_value = (
None if value == 0 else datetime.fromtimestamp(value / 1000.0)
)
setattr(self, field_.name, casted_value)
elif field_.name in (
"is_conflict",
"is_todo",
"todo_completed",
"encryption_applied",
"is_shared",
"encryption_blob_encrypted",
Expand Down Expand Up @@ -151,7 +156,7 @@ class NoteData(BaseData):
source_url: Optional[str] = None
is_todo: Optional[bool] = None
todo_due: Optional[datetime] = None
todo_completed: Optional[bool] = None
todo_completed: Optional[datetime] = None
source: Optional[str] = None
source_application: Optional[str] = None
application_data: Optional[str] = None
Expand Down
5 changes: 4 additions & 1 deletion test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,15 @@ def test_get_notes_valid_properties(self):
"""Try to get specific properties of a note."""
self.api.add_notebook()
self.api.add_note()
# TODO: Some of the fields yield HTTP 500.
selected_fields = dt.NoteData.fields() - {
# TODO: Some of the fields yield HTTP 500.
"body_html",
"base_url",
"image_data_url",
"crop_rect",
# todo timestamps can be None
"todo_due",
"todo_completed",
}
property_combinations = self.get_combinations(selected_fields)
for properties in property_combinations:
Expand Down

0 comments on commit 934df4a

Please sign in to comment.