Skip to content

Commit

Permalink
Implement helpers.is_full_page_or_database
Browse files Browse the repository at this point in the history
  • Loading branch information
ramnes committed Aug 17, 2023
1 parent c038cff commit dc7577e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions notion_client/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ def is_full_database(response: Dict[Any, Any]) -> bool:
return "title" in response


def is_full_page_or_database(response: Dict[Any, Any]) -> bool:
"""Return `true` if `response` is a full database or a full page."""
if response.get("object") == "database":
return is_full_database(response)
return is_full_page(response)


def is_full_user(response: Dict[Any, Any]) -> bool:
"""Return `true` if response is a full user."""
return "type" in response
Expand Down
10 changes: 10 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
is_full_comment,
is_full_database,
is_full_page,
is_full_page_or_database,
is_full_user,
iterate_paginated_api,
pick,
Expand Down Expand Up @@ -132,6 +133,15 @@ def test_is_full_database(client, database_id):
assert is_full_database(response)


@pytest.mark.vcr()
def test_is_full_page_or_database(client, database_id, page_id):
response = client.pages.retrieve(page_id=page_id)
assert is_full_page_or_database(response)

response = client.databases.retrieve(database_id=database_id)
assert is_full_page_or_database(response)


@pytest.mark.vcr()
def test_is_full_user(client):
response = client.users.me()
Expand Down

0 comments on commit dc7577e

Please sign in to comment.