Skip to content

Commit bdfc87a

Browse files
authored
feat: accept the table view style (#270)
1 parent b0a1370 commit bdfc87a

6 files changed

Lines changed: 14 additions & 11 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- `TodoistAPIAsync` now performs true async HTTP I/O with `httpx2.AsyncClient`.
1313
- Support for Python 3.14.
14+
- `add_project` and `update_project` accept the `table` view style.
1415

1516
### Removed
1617

‎tests/test_api_projects.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,41 +160,43 @@ async def test_add_project_minimal(
160160

161161

162162
@pytest.mark.asyncio
163+
@pytest.mark.parametrize("view_style", ["board", "table"])
163164
async def test_add_project_full(
164165
todoist_api: TodoistAPI,
165166
todoist_api_async: TodoistAPIAsync,
166167
respx_mock: respx.MockRouter,
167168
default_project_response: dict[str, Any],
168-
default_project: Project,
169+
view_style: str,
169170
) -> None:
170171
project_name = "A Project"
171172
args: dict[str, Any] = {
172173
"description": "A project description",
173174
"parent_id": "3Ty8VQXxpwv28PK3",
174175
"color": "red",
175176
"is_favorite": True,
176-
"view_style": "board",
177+
"view_style": view_style,
177178
}
179+
project_response = default_project_response | {"view_style": view_style}
178180

179181
mock_route(
180182
respx_mock,
181183
method="POST",
182184
url=f"{DEFAULT_API_URL}/projects",
183185
request_headers=api_headers(),
184186
request_json={"name": project_name} | args,
185-
response_json=default_project_response,
187+
response_json=project_response,
186188
response_status=200,
187189
)
188190

189191
new_project = todoist_api.add_project(name=project_name, **args)
190192

191193
assert len(respx_mock.calls) == 1
192-
assert new_project == default_project
194+
assert new_project == Project.from_dict(project_response)
193195

194196
new_project = await todoist_api_async.add_project(name=project_name, **args)
195197

196198
assert len(respx_mock.calls) == 2
197-
assert new_project == default_project
199+
assert new_project == Project.from_dict(project_response)
198200

199201

200202
@pytest.mark.asyncio

‎todoist_api_python/api.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ def add_project(
740740
:param parent_id: The ID of the parent project. Set to null for root projects.
741741
:param color: The color of the project icon.
742742
:param is_favorite: Whether the project is a favorite.
743-
:param view_style: A string value (either 'list' or 'board', default is 'list').
743+
:param view_style: 'list', 'board', 'calendar' or 'table' (default is 'list').
744744
:return: The newly created project.
745745
:raises httpx2.HTTPStatusError: If the API request fails.
746746
:raises TypeError: If the API response is not a valid Project dictionary.
@@ -788,7 +788,7 @@ def update_project(
788788
:param description: Description for the project (up to 1024 characters).
789789
:param color: The color of the project icon.
790790
:param is_favorite: Whether the project is a favorite.
791-
:param view_style: A string value (either 'list' or 'board').
791+
:param view_style: 'list', 'board', 'calendar' or 'table'.
792792
:param order: Position of the project among projects with the same parent.
793793
:param collapsed: Whether the project's sub-projects are collapsed.
794794
:return: the updated Project.

‎todoist_api_python/api_async.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ async def add_project(
760760
:param parent_id: The ID of the parent project. Set to null for root projects.
761761
:param color: The color of the project icon.
762762
:param is_favorite: Whether the project is a favorite.
763-
:param view_style: A string value (either 'list' or 'board', default is 'list').
763+
:param view_style: 'list', 'board', 'calendar' or 'table' (default is 'list').
764764
:return: The newly created project.
765765
:raises httpx2.HTTPStatusError: If the API request fails.
766766
:raises TypeError: If the API response is not a valid Project dictionary.
@@ -808,7 +808,7 @@ async def update_project(
808808
:param description: Description for the project (up to 1024 characters).
809809
:param color: The color of the project icon.
810810
:param is_favorite: Whether the project is a favorite.
811-
:param view_style: A string value (either 'list' or 'board').
811+
:param view_style: 'list', 'board', 'calendar' or 'table'.
812812
:param order: Position of the project among projects with the same parent.
813813
:param collapsed: Whether the project's sub-projects are collapsed.
814814
:return: the updated Project.

‎todoist_api_python/models.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from todoist_api_python._core.endpoints import INBOX_URL, get_project_url, get_task_url
1111

12-
ViewStyle = Literal["list", "board", "calendar"]
12+
ViewStyle = Literal["list", "board", "calendar", "table"]
1313
DurationUnit = Literal["minute", "day"]
1414
ReminderType = Literal["relative", "absolute"]
1515
ReminderService = Literal["email", "push"]

‎todoist_api_python/types.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
]
3636
ViewStyle = Annotated[
3737
str,
38-
Predicate(lambda value: value in ("list", "board", "calendar")),
38+
Predicate(lambda value: value in ("list", "board", "calendar", "table")),
3939
]
4040

4141
__all__ = ["ColorString", "LanguageCode", "ViewStyle"]

0 commit comments

Comments
 (0)