Skip to content

Commit b75ebc8

Browse files
jorwoodsjacalata
authored andcommitted
fix: datasource owner/project missing parsing (#1700)
Eric Summers pointed out that when the User Visibility setting is set to "Limited," TSC fails to parse because it can't retrieve any owner information. This bug is due to an `UnboundLocalError` where the `owner` and `project` variables were not assigned in cases where the owner and project elements were not included in the XML response. This PR also includes a test for the parsing where the owner and project elements are missing and properly set to `None` on the DatasourceItem. Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
1 parent 6415917 commit b75ebc8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/test_datasource.py

Lines changed: 11 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"
@@ -850,3 +851,13 @@ def test_get_datasource_all_fields(server) -> None:
850851
assert datasources[0].owner.last_login == parse_datetime("2025-02-04T06:39:20Z")
851852
assert datasources[0].owner.name == "bob@example.com"
852853
assert datasources[0].owner.site_role == "SiteAdministratorCreator"
854+
855+
856+
def test_get_datasource_no_owner(server: TSC.Server) -> None:
857+
with requests_mock.mock() as m:
858+
m.get(server.datasources.baseurl, text=GET_NO_OWNER.read_text())
859+
datasources, _ = server.datasources.get()
860+
861+
datasource = datasources[0]
862+
assert datasource.owner is None
863+
assert datasource.project is None

0 commit comments

Comments
 (0)