Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Support for moving tasks, courtesy of @radiant-tangent
- Re-add support for `X-Request-ID`
- Configurable via `request_id_fn` API constructor argument
- Defaults to random UUID v4
- Automatic testing across all supported Python versions

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions tests/data/test_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class PaginatedItems(TypedDict):

DEFAULT_TOKEN = "some-default-token"

DEFAULT_REQUEST_ID = "f00dbeef-cafe-4bad-a555-deadc0decafe"

DEFAULT_DUE_RESPONSE = {
"date": "2016-09-01",
"timezone": "Europe/Moscow",
Expand Down
26 changes: 0 additions & 26 deletions tests/test_api_async.py

This file was deleted.

9 changes: 6 additions & 3 deletions tests/test_api_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
data_matcher,
enumerate_async,
param_matcher,
request_id_matcher,
)
from todoist_api_python.models import Attachment

Expand All @@ -40,7 +41,7 @@ async def test_get_comment(
url=endpoint,
json=default_comment_response,
status=200,
match=[auth_matcher()],
match=[auth_matcher(), request_id_matcher()],
)

comment = todoist_api.get_comment(comment_id)
Expand Down Expand Up @@ -74,6 +75,7 @@ async def test_get_comments(
status=200,
match=[
auth_matcher(),
request_id_matcher(),
param_matcher({"task_id": task_id}, cursor),
],
)
Expand Down Expand Up @@ -120,6 +122,7 @@ async def test_add_comment(
status=200,
match=[
auth_matcher(),
request_id_matcher(),
data_matcher(
{
"content": content,
Expand Down Expand Up @@ -166,7 +169,7 @@ async def test_update_comment(
url=f"{DEFAULT_API_URL}/comments/{default_comment.id}",
json=updated_comment_dict,
status=200,
match=[auth_matcher(), data_matcher(args)],
match=[auth_matcher(), request_id_matcher(), data_matcher(args)],
)

response = todoist_api.update_comment(comment_id=default_comment.id, **args)
Expand Down Expand Up @@ -195,7 +198,7 @@ async def test_delete_comment(
method=responses.DELETE,
url=endpoint,
status=204,
match=[auth_matcher()],
match=[auth_matcher(), request_id_matcher()],
)

response = todoist_api.delete_comment(comment_id)
Expand Down
11 changes: 8 additions & 3 deletions tests/test_api_completed_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
import responses

from tests.data.test_defaults import DEFAULT_API_URL, PaginatedItems
from tests.utils.test_utils import auth_matcher, enumerate_async, param_matcher
from tests.utils.test_utils import (
auth_matcher,
enumerate_async,
param_matcher,
request_id_matcher,
)
from todoist_api_python._core.utils import format_datetime

if TYPE_CHECKING:
Expand Down Expand Up @@ -51,7 +56,7 @@ async def test_get_completed_tasks_by_due_date(
url=endpoint,
json=page,
status=200,
match=[auth_matcher(), param_matcher(params, cursor)],
match=[auth_matcher(), request_id_matcher(), param_matcher(params, cursor)],
)
cursor = page["next_cursor"]

Expand Down Expand Up @@ -111,7 +116,7 @@ async def test_get_completed_tasks_by_completion_date(
url=endpoint,
json=page,
status=200,
match=[auth_matcher(), param_matcher(params, cursor)],
match=[auth_matcher(), request_id_matcher(), param_matcher(params, cursor)],
)
cursor = page["next_cursor"]

Expand Down
17 changes: 13 additions & 4 deletions tests/test_api_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
data_matcher,
enumerate_async,
param_matcher,
request_id_matcher,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -66,7 +67,7 @@ async def test_get_labels(
url=endpoint,
json=page,
status=200,
match=[auth_matcher(), param_matcher({}, cursor)],
match=[auth_matcher(), request_id_matcher(), param_matcher({}, cursor)],
)
cursor = page["next_cursor"]

Expand Down Expand Up @@ -102,7 +103,11 @@ async def test_add_label_minimal(
url=f"{DEFAULT_API_URL}/labels",
json=default_label_response,
status=200,
match=[auth_matcher(), data_matcher({"name": label_name})],
match=[
auth_matcher(),
request_id_matcher(),
data_matcher({"name": label_name}),
],
)

new_label = todoist_api.add_label(name=label_name)
Expand Down Expand Up @@ -136,7 +141,11 @@ async def test_add_label_full(
url=f"{DEFAULT_API_URL}/labels",
json=default_label_response,
status=200,
match=[auth_matcher(), data_matcher({"name": label_name} | args)],
match=[
auth_matcher(),
request_id_matcher(),
data_matcher({"name": label_name} | args),
],
)

new_label = todoist_api.add_label(name=label_name, **args)
Expand Down Expand Up @@ -167,7 +176,7 @@ async def test_update_label(
url=f"{DEFAULT_API_URL}/labels/{default_label.id}",
json=updated_label_dict,
status=200,
match=[auth_matcher(), data_matcher(args)],
match=[auth_matcher(), request_id_matcher(), data_matcher(args)],
)

response = todoist_api.update_label(label_id=default_label.id, **args)
Expand Down
25 changes: 17 additions & 8 deletions tests/test_api_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
data_matcher,
enumerate_async,
param_matcher,
request_id_matcher,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -66,7 +67,7 @@ async def test_get_projects(
url=endpoint,
json=page,
status=200,
match=[auth_matcher(), param_matcher({}, cursor)],
match=[auth_matcher(), request_id_matcher(), param_matcher({}, cursor)],
)
cursor = page["next_cursor"]

Expand Down Expand Up @@ -102,7 +103,11 @@ async def test_add_project_minimal(
url=f"{DEFAULT_API_URL}/projects",
json=default_project_response,
status=200,
match=[auth_matcher(), data_matcher({"name": project_name})],
match=[
auth_matcher(),
request_id_matcher(),
data_matcher({"name": project_name}),
],
)

new_project = todoist_api.add_project(name=project_name)
Expand Down Expand Up @@ -131,7 +136,11 @@ async def test_add_project_full(
url=f"{DEFAULT_API_URL}/projects",
json=default_project_response,
status=200,
match=[auth_matcher(), data_matcher({"name": project_name})],
match=[
auth_matcher(),
request_id_matcher(),
data_matcher({"name": project_name}),
],
)

new_project = todoist_api.add_project(name=project_name)
Expand Down Expand Up @@ -164,7 +173,7 @@ async def test_update_project(
url=f"{DEFAULT_API_URL}/projects/{default_project.id}",
json=updated_project_dict,
status=200,
match=[auth_matcher(), data_matcher(args)],
match=[auth_matcher(), request_id_matcher(), data_matcher(args)],
)

response = todoist_api.update_project(project_id=default_project.id, **args)
Expand Down Expand Up @@ -198,7 +207,7 @@ async def test_archive_project(
url=endpoint,
json=archived_project_dict,
status=200,
match=[auth_matcher()],
match=[auth_matcher(), request_id_matcher()],
)

project = todoist_api.archive_project(project_id)
Expand Down Expand Up @@ -230,7 +239,7 @@ async def test_unarchive_project(
url=endpoint,
json=unarchived_project_dict,
status=200,
match=[auth_matcher()],
match=[auth_matcher(), request_id_matcher()],
)

project = todoist_api.unarchive_project(project_id)
Expand All @@ -257,7 +266,7 @@ async def test_delete_project(
method=responses.DELETE,
url=endpoint,
status=204,
match=[auth_matcher()],
match=[auth_matcher(), request_id_matcher()],
)

response = todoist_api.delete_project(project_id)
Expand Down Expand Up @@ -289,7 +298,7 @@ async def test_get_collaborators(
url=endpoint,
json=page,
status=200,
match=[auth_matcher(), param_matcher({}, cursor)],
match=[auth_matcher(), request_id_matcher(), param_matcher({}, cursor)],
)
cursor = page["next_cursor"]

Expand Down
9 changes: 6 additions & 3 deletions tests/test_api_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
data_matcher,
enumerate_async,
param_matcher,
request_id_matcher,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -66,7 +67,7 @@ async def test_get_sections(
url=endpoint,
json=page,
status=200,
match=[auth_matcher(), param_matcher({}, cursor)],
match=[auth_matcher(), request_id_matcher(), param_matcher({}, cursor)],
)
cursor = page["next_cursor"]

Expand Down Expand Up @@ -107,6 +108,7 @@ async def test_get_sections_by_project(
status=200,
match=[
auth_matcher(),
request_id_matcher(),
param_matcher({"project_id": project_id}, cursor),
],
)
Expand Down Expand Up @@ -150,6 +152,7 @@ async def test_add_section(
status=200,
match=[
auth_matcher(),
request_id_matcher(),
data_matcher({"name": section_name, "project_id": project_id} | args),
],
)
Expand Down Expand Up @@ -186,7 +189,7 @@ async def test_update_section(
url=f"{DEFAULT_API_URL}/sections/{default_section.id}",
json=updated_section_dict,
status=200,
match=[auth_matcher(), data_matcher(args)],
match=[auth_matcher(), request_id_matcher(), data_matcher(args)],
)

response = todoist_api.update_section(section_id=default_section.id, **args)
Expand Down Expand Up @@ -215,7 +218,7 @@ async def test_delete_section(
method=responses.DELETE,
url=endpoint,
status=204,
match=[auth_matcher()],
match=[auth_matcher(), request_id_matcher()],
)

response = todoist_api.delete_section(section_id)
Expand Down
Loading