Skip to content

Commit 757a7b8

Browse files
committed
fix: add entity_type_name returning None to OneNote Section and Notebook — prevent @odata.type rejection by OneNote API
1 parent 04a6404 commit 757a7b8

4 files changed

Lines changed: 18 additions & 10 deletions

File tree

office365/onenote/notebooks/notebook.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ def section_groups(self):
3939
ResourcePath("sectionGroups", self.resource_path),
4040
),
4141
)
42+
43+
@property
44+
def entity_type_name(self):
45+
return None # type: ignore

office365/onenote/sections/section.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,7 @@ def parent_section_group(self) -> SectionGroup:
9999
"parentSectionGroup",
100100
SectionGroup(self.context, ResourcePath("parentSectionGroup", self.resource_path)),
101101
)
102+
103+
@property
104+
def entity_type_name(self):
105+
return None # type: ignore

tests/onenote/test_page.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def test_02_page_has_expected_properties(self):
6060
if not page:
6161
self.skipTest("No page created from previous test")
6262

63-
self.assertIsNotNone(page.get_property("title"))
64-
self.assertIsNotNone(page.get_property("createdDateTime"))
63+
self.assertIsNotNone(page.title)
64+
self.assertIsNotNone(page.created_datetime)
6565
# links should contain parentNotebook and parentSection URLs
66-
self.assertIsNotNone(page.get_property("links"))
66+
self.assertIsNotNone(page.links)
6767

6868
@requires_delegated(
6969
"Notes.Read",
@@ -94,7 +94,7 @@ def test_04_page_title_includes_html_title(self):
9494
if not page:
9595
self.skipTest("No page created from previous test")
9696

97-
title = page.get_property("title")
97+
title = page.title
9898
if title:
9999
self.assertIsInstance(title, str)
100100
self.assertGreater(len(title), 0)

tests/onenote/test_section.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ def test_02_create_notebook_and_section(self):
5050
notebook_name = create_unique_name("SDK Test Notebook")
5151
notebook = self.client.me.onenote.notebooks.add(notebook_name).execute_query()
5252
self.assertIsNotNone(notebook.resource_path)
53-
self.assertEqual(notebook.get_property("displayName"), notebook_name)
53+
self.assertEqual(notebook.display_name, notebook_name)
5454
TestSection.target_notebook = notebook
5555

5656
section_name = create_unique_name("SDK Test Section")
5757
section = notebook.sections.add(displayName=section_name).execute_query()
5858
self.assertIsNotNone(section.resource_path)
59-
self.assertEqual(section.get_property("displayName"), section_name)
59+
self.assertEqual(section.display_name, section_name)
6060
TestSection.target_section = section
6161

6262
@requires_delegated(
@@ -72,7 +72,7 @@ def test_03_update_section_name(self):
7272

7373
new_name = create_unique_name("SDK Updated Section")
7474
section.set_property("displayName", new_name).update().execute_query()
75-
self.assertEqual(section.get_property("displayName"), new_name)
75+
self.assertEqual(section.display_name, new_name)
7676

7777
@requires_delegated(
7878
"Notes.Read",
@@ -87,9 +87,9 @@ def test_04_section_has_expected_properties(self):
8787
if not section:
8888
self.skipTest("No section created from previous test")
8989

90-
self.assertIsNotNone(section.get_property("displayName"))
91-
self.assertIsNotNone(section.get_property("createdDateTime"))
92-
self.assertIsNotNone(section.get_property("isDefault"))
90+
self.assertIsNotNone(section.display_name)
91+
self.assertIsNotNone(section.created_datetime)
92+
self.assertIsNotNone(section.is_default)
9393

9494
@requires_delegated(
9595
"Notes.Read",

0 commit comments

Comments
 (0)