|
22 | 22 | GET_EMPTY_XML = os.path.join(TEST_ASSET_DIR, "workbook_get_empty.xml") |
23 | 23 | GET_INVALID_DATE_XML = os.path.join(TEST_ASSET_DIR, "workbook_get_invalid_date.xml") |
24 | 24 | GET_XML = os.path.join(TEST_ASSET_DIR, "workbook_get.xml") |
| 25 | +ODATA_XML = os.path.join(TEST_ASSET_DIR, "odata_connection.xml") |
25 | 26 | POPULATE_CONNECTIONS_XML = os.path.join(TEST_ASSET_DIR, "workbook_populate_connections.xml") |
26 | 27 | POPULATE_PDF = os.path.join(TEST_ASSET_DIR, "populate_pdf.pdf") |
27 | 28 | POPULATE_POWERPOINT = os.path.join(TEST_ASSET_DIR, "populate_powerpoint.pptx") |
@@ -862,3 +863,31 @@ def test_bad_download_response(self) -> None: |
862 | 863 | ) |
863 | 864 | file_path = self.server.workbooks.download("9dbd2263-16b5-46e1-9c43-a76bb8ab65fb", td) |
864 | 865 | self.assertTrue(os.path.exists(file_path)) |
| 866 | + |
| 867 | + def test_odata_connection(self) -> None: |
| 868 | + self.baseurl = self.server.workbooks.baseurl |
| 869 | + workbook = TSC.WorkbookItem("project", "test") |
| 870 | + workbook._id = "06b944d2-959d-4604-9305-12323c95e70e" |
| 871 | + connection = TSC.ConnectionItem() |
| 872 | + url = "https://odata.website.com/TestODataEndpoint" |
| 873 | + connection.server_address = url |
| 874 | + connection._connection_type = "odata" |
| 875 | + connection._id = "17376070-64d1-4d17-acb4-a56e4b5b1768" |
| 876 | + |
| 877 | + creds = TSC.ConnectionCredentials("", "", True) |
| 878 | + connection.connection_credentials = creds |
| 879 | + with open(ODATA_XML, "rb") as f: |
| 880 | + response_xml = f.read().decode("utf-8") |
| 881 | + |
| 882 | + with requests_mock.mock() as m: |
| 883 | + m.put(f"{self.baseurl}/{workbook.id}/connections/{connection.id}", text=response_xml) |
| 884 | + self.server.workbooks.update_connection(workbook, connection) |
| 885 | + |
| 886 | + history = m.request_history |
| 887 | + |
| 888 | + request = history[0] |
| 889 | + xml = fromstring(request.body) |
| 890 | + xml_connection = xml.find(".//connection") |
| 891 | + |
| 892 | + assert xml_connection is not None |
| 893 | + self.assertEqual(xml_connection.get("serverAddress"), url) |
0 commit comments