Skip to content

Commit dc7577e

Browse files
committed
Implement helpers.is_full_page_or_database
1 parent c038cff commit dc7577e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

notion_client/helpers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ def is_full_database(response: Dict[Any, Any]) -> bool:
8989
return "title" in response
9090

9191

92+
def is_full_page_or_database(response: Dict[Any, Any]) -> bool:
93+
"""Return `true` if `response` is a full database or a full page."""
94+
if response.get("object") == "database":
95+
return is_full_database(response)
96+
return is_full_page(response)
97+
98+
9299
def is_full_user(response: Dict[Any, Any]) -> bool:
93100
"""Return `true` if response is a full user."""
94101
return "type" in response

tests/test_helpers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
is_full_comment,
1313
is_full_database,
1414
is_full_page,
15+
is_full_page_or_database,
1516
is_full_user,
1617
iterate_paginated_api,
1718
pick,
@@ -132,6 +133,15 @@ def test_is_full_database(client, database_id):
132133
assert is_full_database(response)
133134

134135

136+
@pytest.mark.vcr()
137+
def test_is_full_page_or_database(client, database_id, page_id):
138+
response = client.pages.retrieve(page_id=page_id)
139+
assert is_full_page_or_database(response)
140+
141+
response = client.databases.retrieve(database_id=database_id)
142+
assert is_full_page_or_database(response)
143+
144+
135145
@pytest.mark.vcr()
136146
def test_is_full_user(client):
137147
response = client.users.me()

0 commit comments

Comments
 (0)