Skip to content

Commit 150a2eb

Browse files
committed
chore: test to verify datasource refresh body
1 parent 5356dc2 commit 150a2eb

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

test/test_datasource.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,24 @@ def test_refresh_object(self) -> None:
366366
# We only check the `id`; remaining fields are already tested in `test_refresh_id`
367367
self.assertEqual("7c3d599e-949f-44c3-94a1-f30ba85757e4", new_job.id)
368368

369+
def test_datasource_refresh_request_empty(self) -> None:
370+
self.server.version = "2.8"
371+
self.baseurl = self.server.datasources.baseurl
372+
item = TSC.DatasourceItem("")
373+
item._id = "1234"
374+
text = read_xml_asset(REFRESH_XML)
375+
def match_request_body(request):
376+
try:
377+
root = fromstring(request.body)
378+
assert root.tag == "tsRequest"
379+
assert len(root) == 0
380+
return True
381+
except Exception:
382+
return False
383+
384+
with requests_mock.mock() as m:
385+
m.post(f"{self.baseurl}/1234/refresh", text=text, additional_matcher=match_request_body)
386+
369387
def test_update_hyper_data_datasource_object(self) -> None:
370388
"""Calling `update_hyper_data` with a `DatasourceItem` should update that datasource"""
371389
self.server.version = "3.13"

0 commit comments

Comments
 (0)