Skip to content

Commit 659a445

Browse files
jorwoodsjacalata
andcommitted
fix: datasource description update and publish (#1682)
* fix: datasource description update and publish Publish and update datasource were missing adding in the description to the XML. This PR adds it in. Co-authored-by: raccoooonz * ci: trigger * chore: test publish contains description --------- Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com> Co-authored-by: Jac <jacalata@users.noreply.github.com>
1 parent b75ebc8 commit 659a445

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/test_datasource.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,49 @@ def test_get_datasource_all_fields(server) -> None:
853853
assert datasources[0].owner.site_role == "SiteAdministratorCreator"
854854

855855

856+
def test_update_description(server: TSC.Server) -> None:
857+
response_xml = UPDATE_XML.read_text()
858+
with requests_mock.mock() as m:
859+
m.put(server.datasources.baseurl + "/9dbd2263-16b5-46e1-9c43-a76bb8ab65fb", text=response_xml)
860+
single_datasource = TSC.DatasourceItem("1d0304cd-3796-429f-b815-7258370b9b74", "Sample datasource")
861+
single_datasource.owner_id = "dd2239f6-ddf1-4107-981a-4cf94e415794"
862+
single_datasource._content_url = "Sampledatasource"
863+
single_datasource._id = "9dbd2263-16b5-46e1-9c43-a76bb8ab65fb"
864+
single_datasource.certified = True
865+
single_datasource.certification_note = "Warning, here be dragons."
866+
single_datasource.description = "Sample description"
867+
_ = server.datasources.update(single_datasource)
868+
869+
history = m.request_history[0]
870+
body = fromstring(history.body)
871+
ds_elem = body.find(".//datasource")
872+
assert ds_elem is not None
873+
assert ds_elem.attrib["description"] == "Sample description"
874+
875+
876+
def test_publish_description(server: TSC.Server) -> None:
877+
response_xml = PUBLISH_XML.read_text()
878+
with requests_mock.mock() as m:
879+
m.post(server.datasources.baseurl, text=response_xml)
880+
single_datasource = TSC.DatasourceItem("1d0304cd-3796-429f-b815-7258370b9b74", "Sample datasource")
881+
single_datasource.owner_id = "dd2239f6-ddf1-4107-981a-4cf94e415794"
882+
single_datasource._content_url = "Sampledatasource"
883+
single_datasource._id = "9dbd2263-16b5-46e1-9c43-a76bb8ab65fb"
884+
single_datasource.certified = True
885+
single_datasource.certification_note = "Warning, here be dragons."
886+
single_datasource.description = "Sample description"
887+
_ = server.datasources.publish(single_datasource, TEST_ASSET_DIR / "SampleDS.tds", server.PublishMode.CreateNew)
888+
889+
history = m.request_history[0]
890+
boundary = history.body[: history.body.index(b"\r\n")].strip()
891+
parts = history.body.split(boundary)
892+
request_payload = next(part for part in parts if b"request_payload" in part)
893+
xml_payload = request_payload.strip().split(b"\r\n")[-1]
894+
body = fromstring(xml_payload)
895+
ds_elem = body.find(".//datasource")
896+
assert ds_elem is not None
897+
assert ds_elem.attrib["description"] == "Sample description"
898+
856899
def test_get_datasource_no_owner(server: TSC.Server) -> None:
857900
with requests_mock.mock() as m:
858901
m.get(server.datasources.baseurl, text=GET_NO_OWNER.read_text())

0 commit comments

Comments
 (0)