Skip to content

Commit 0c50fd6

Browse files
authored
Merge branch 'development' into jorwoods/datasource_description
2 parents e9e0999 + 0f706c6 commit 0c50fd6

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#ECCN:Open Source
2+
#GUSINFO:Open Source,Open Source Workflow

tableauserverclient/models/datasource_item.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,15 @@ def _parse_element(datasource_xml: ET.Element, ns: dict) -> tuple:
535535

536536
project_id = None
537537
project_name = None
538+
project = None
538539
project_elem = datasource_xml.find(".//t:project", namespaces=ns)
539540
if project_elem is not None:
540541
project = ProjectItem.from_xml(project_elem, ns)
541542
project_id = project_elem.get("id", None)
542543
project_name = project_elem.get("name", None)
543544

544545
owner_id = None
546+
owner = None
545547
owner_elem = datasource_xml.find(".//t:owner", namespaces=ns)
546548
if owner_elem is not None:
547549
owner = UserItem.from_xml(owner_elem, ns)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.3.xsd">
3+
<pagination pageNumber="1" pageSize="100" totalAvailable="2" />
4+
<datasources>
5+
<datasource id="e76a1461-3b1d-4588-bf1b-17551a879ad9" name="SampleDS" size="4096" contentUrl="SampleDS" description="SampleDsDescription" type="dataengine" createdAt="2016-08-11T21:22:40Z" updatedAt="2016-08-11T21:34:17Z" encryptExtracts="false" hasExtracts="true" useRemoteQueryAgent="false" webpageUrl="https://web.com">
6+
<tags />
7+
</datasource>
8+
<datasource id="9dbd2263-16b5-46e1-9c43-a76bb8ab65fb" name="Sample datasource" description="description Sample" size="10240" contentUrl="Sampledatasource" type="dataengine" createdAt="2016-08-04T21:31:55Z" updatedAt="2016-08-04T21:31:55Z" encryptExtracts="true" hasExtracts="false" useRemoteQueryAgent="true" webpageUrl="https://page.com">
9+
<tags>
10+
<tag label="world" />
11+
<tag label="indicators" />
12+
<tag label="sample" />
13+
</tags>
14+
</datasource>
15+
</datasources>
16+
</tsResponse>

test/test_datasource.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
GET_EMPTY_XML = TEST_ASSET_DIR / "datasource_get_empty.xml"
2525
GET_BY_ID_XML = TEST_ASSET_DIR / "datasource_get_by_id.xml"
2626
GET_XML_ALL_FIELDS = TEST_ASSET_DIR / "datasource_get_all_fields.xml"
27+
GET_NO_OWNER = TEST_ASSET_DIR / "datasource_get_no_owner.xml"
2728
POPULATE_CONNECTIONS_XML = TEST_ASSET_DIR / "datasource_populate_connections.xml"
2829
POPULATE_PERMISSIONS_XML = TEST_ASSET_DIR / "datasource_populate_permissions.xml"
2930
PUBLISH_XML = TEST_ASSET_DIR / "datasource_publish.xml"
@@ -894,3 +895,12 @@ def test_publish_description(server: TSC.Server) -> None:
894895
ds_elem = body.find(".//datasource")
895896
assert ds_elem is not None
896897
assert ds_elem.attrib["description"] == "Sample description"
898+
899+
def test_get_datasource_no_owner(server: TSC.Server) -> None:
900+
with requests_mock.mock() as m:
901+
m.get(server.datasources.baseurl, text=GET_NO_OWNER.read_text())
902+
datasources, _ = server.datasources.get()
903+
904+
datasource = datasources[0]
905+
assert datasource.owner is None
906+
assert datasource.project is None

0 commit comments

Comments
 (0)