Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure nullable attributes icon and cover are set to None #220

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 6 additions & 1 deletion notion_client/api_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,15 @@ def update(self, page_id: str, **kwargs: Any) -> SyncAsync[Any]:

*[🔗 Endpoint documentation](https://developers.notion.com/reference/patch-page)*
""" # noqa: E501
body = pick(kwargs, "archived", "properties", "icon", "cover")
for nullable_attr in ("icon", "cover"): # make sure those are set to `None`
if kwargs.get(nullable_attr, object) is None:
body[nullable_attr] = None

return self.parent.request(
path=f"pages/{page_id}",
method="PATCH",
body=pick(kwargs, "archived", "properties", "icon", "cover"),
body=body,
auth=kwargs.get("auth"),
)

Expand Down
6 changes: 5 additions & 1 deletion tests/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def test_pages_update(client, page_id):

response = client.pages.update(page_id=page_id, icon=icon)
assert response["icon"]


# delete icon again
response = client.pages.update(page_id=page_id, icon=None)
assert response["icon"] is None


@pytest.mark.vcr()
def test_pages_properties_retrieve(client, page_id):
Expand Down
Loading