Skip to content

Commit 1d98899

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

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/test_datasource.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,25 @@ 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+
376+
def match_request_body(request):
377+
try:
378+
root = fromstring(request.body)
379+
assert root.tag == "tsRequest"
380+
assert len(root) == 0
381+
return True
382+
except Exception:
383+
return False
384+
385+
with requests_mock.mock() as m:
386+
m.post(f"{self.baseurl}/1234/refresh", text=text, additional_matcher=match_request_body)
387+
369388
def test_update_hyper_data_datasource_object(self) -> None:
370389
"""Calling `update_hyper_data` with a `DatasourceItem` should update that datasource"""
371390
self.server.version = "3.13"

0 commit comments

Comments
 (0)