Skip to content

Commit

Permalink
Fix shared attribute for custom views
Browse files Browse the repository at this point in the history
  • Loading branch information
jorwoods committed Sep 17, 2023
1 parent 5a5772c commit 12cd9ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tableauserverclient/models/custom_view_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def from_xml_element(cls, parsed_response, ns, workbook_id="") -> List["CustomVi
cv_item._content_url = custom_view_xml.get("contentUrl", None)
cv_item._id = custom_view_xml.get("id", None)
cv_item._name = custom_view_xml.get("name", None)
cv_item._shared = string_to_bool(custom_view_xml.get("shared", None))

if owner_elem is not None:
parsed_owners = UserItem.from_response_as_owner(tostring(custom_view_xml), ns)
Expand All @@ -154,3 +155,7 @@ def from_xml_element(cls, parsed_response, ns, workbook_id="") -> List["CustomVi

all_view_items.append(cv_item)
return all_view_items


def string_to_bool(s: str | None) -> bool:
return (s or "").lower() == "true"
3 changes: 2 additions & 1 deletion test/test_custom_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ def test_get(self) -> None:
self.assertEqual("5de011f8-5aa9-4d5b-b991-f462c8dd6bb7", all_views[0].owner.id)
self.assertIsNone(all_views[0].created_at)
self.assertIsNone(all_views[0].updated_at)
self.assertFalse(all_views[0].shared)

self.assertEqual("fd252f73-593c-4c4e-8584-c032b8022adc", all_views[1].id)
self.assertEqual("Overview", all_views[1].name)
self.assertEqual(False, all_views[1].shared)
self.assertEqual("6d13b0ca-043d-4d42-8c9d-3f3313ea3a00", all_views[1].workbook.id)
self.assertEqual("5de011f8-5aa9-4d5b-b991-f462c8dd6bb7", all_views[1].owner.id)
self.assertEqual("2002-05-30T09:00:00Z", format_datetime(all_views[1].created_at))
self.assertEqual("2002-06-05T08:00:59Z", format_datetime(all_views[1].updated_at))
self.assertTrue(all_views[1].shared)

def test_get_by_id(self) -> None:
with open(GET_XML_ID, "rb") as f:
Expand Down

0 comments on commit 12cd9ba

Please sign in to comment.