Skip to content

Commit fe588bd

Browse files
authored
Revert "Jac/small things (#1215)"
This reverts commit 4fb6180.
1 parent 4fb6180 commit fe588bd

File tree

6 files changed

+16
-40
lines changed

6 files changed

+16
-40
lines changed

tableauserverclient/models/datasource_item.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __repr__(self):
3232
self.project_id,
3333
)
3434

35-
def __init__(self, project_id: Optional[str] = None, name: Optional[str] = None) -> None:
35+
def __init__(self, project_id: str, name: Optional[str] = None) -> None:
3636
self._ask_data_enablement = None
3737
self._certified = None
3838
self._certification_note = None
@@ -135,11 +135,12 @@ def id(self) -> Optional[str]:
135135
return self._id
136136

137137
@property
138-
def project_id(self) -> Optional[str]:
138+
def project_id(self) -> str:
139139
return self._project_id
140140

141141
@project_id.setter
142-
def project_id(self, value: Optional[str]):
142+
@property_not_nullable
143+
def project_id(self, value: str):
143144
self._project_id = value
144145

145146
@property

tableauserverclient/server/endpoint/workbooks_endpoint.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ def publish(
309309
as_job: bool = False,
310310
hidden_views: Optional[Sequence[str]] = None,
311311
skip_connection_check: bool = False,
312-
parameters=None,
313312
):
314313
if connection_credentials is not None:
315314
import warnings
@@ -413,7 +412,7 @@ def publish(
413412

414413
# Send the publishing request to server
415414
try:
416-
server_response = self.post_request(url, xml_request, content_type, parameters)
415+
server_response = self.post_request(url, xml_request, content_type)
417416
except InternalServerError as err:
418417
if err.code == 504 and not as_job:
419418
err.content = "Timeout error while publishing. Please use asynchronous publishing to avoid timeouts."

tableauserverclient/server/request_factory.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
if TYPE_CHECKING:
1010
from tableauserverclient.server import Server
1111

12-
# this file could be largely replaced if we were willing to import the huge file from generateDS
13-
1412

1513
def _add_multipart(parts: Dict) -> Tuple[Any, str]:
1614
mime_multipart_parts = list()
@@ -148,28 +146,21 @@ def update_req(self, database_item):
148146

149147

150148
class DatasourceRequest(object):
151-
def _generate_xml(self, datasource_item: DatasourceItem, connection_credentials=None, connections=None):
149+
def _generate_xml(self, datasource_item, connection_credentials=None, connections=None):
152150
xml_request = ET.Element("tsRequest")
153151
datasource_element = ET.SubElement(xml_request, "datasource")
154-
if datasource_item.name:
155-
datasource_element.attrib["name"] = datasource_item.name
152+
datasource_element.attrib["name"] = datasource_item.name
156153
if datasource_item.description:
157154
datasource_element.attrib["description"] = str(datasource_item.description)
158155
if datasource_item.use_remote_query_agent is not None:
159156
datasource_element.attrib["useRemoteQueryAgent"] = str(datasource_item.use_remote_query_agent).lower()
160157

161158
if datasource_item.ask_data_enablement:
162159
ask_data_element = ET.SubElement(datasource_element, "askData")
163-
ask_data_element.attrib["enablement"] = datasource_item.ask_data_enablement.__str__()
164-
165-
if datasource_item.certified:
166-
datasource_element.attrib["isCertified"] = datasource_item.certified.__str__()
167-
if datasource_item.certification_note:
168-
datasource_element.attrib["certificationNote"] = datasource_item.certification_note
160+
ask_data_element.attrib["enablement"] = datasource_item.ask_data_enablement
169161

170-
if datasource_item.project_id:
171-
project_element = ET.SubElement(datasource_element, "project")
172-
project_element.attrib["id"] = datasource_item.project_id
162+
project_element = ET.SubElement(datasource_element, "project")
163+
project_element.attrib["id"] = datasource_item.project_id
173164

174165
if connection_credentials is not None and connections is not None:
175166
raise RuntimeError("You cannot set both `connections` and `connection_credentials`")

tableauserverclient/server/request_options.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class Operator:
3838
class Field:
3939
Args = "args"
4040
CompletedAt = "completedAt"
41-
ContentUrl = "contentUrl"
4241
CreatedAt = "createdAt"
4342
DomainName = "domainName"
4443
DomainNickname = "domainNickname"
@@ -148,7 +147,7 @@ def get_query_params(self):
148147
return params
149148

150149

151-
class ExcelRequestOptions(_FilterOptionsBase):
150+
class ExcelRequestOptions(RequestOptionsBase):
152151
def __init__(self, maxage: int = -1) -> None:
153152
super().__init__()
154153
self.max_age = maxage

test/test_datasource_model.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44

55
class DatasourceModelTests(unittest.TestCase):
6-
def test_nullable_project_id(self):
7-
datasource = TSC.DatasourceItem(name="10")
8-
self.assertEqual(datasource.project_id, None)
6+
def test_invalid_project_id(self):
7+
self.assertRaises(ValueError, TSC.DatasourceItem, None)
8+
datasource = TSC.DatasourceItem("10")
9+
with self.assertRaises(ValueError):
10+
datasource.project_id = None
911

1012
def test_require_boolean_flag_bridge_fail(self):
1113
datasource = TSC.DatasourceItem("10")

test/test_view.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,3 @@ def test_populate_excel(self) -> None:
299299

300300
excel_file = b"".join(single_view.excel)
301301
self.assertEqual(response, excel_file)
302-
303-
def test_filter_excel(self) -> None:
304-
self.server.version = "3.8"
305-
self.baseurl = self.server.views.baseurl
306-
with open(POPULATE_EXCEL, "rb") as f:
307-
response = f.read()
308-
with requests_mock.mock() as m:
309-
m.get(self.baseurl + "/d79634e1-6063-4ec9-95ff-50acbf609ff5/crosstab/excel?maxAge=1", content=response)
310-
single_view = TSC.ViewItem()
311-
single_view._id = "d79634e1-6063-4ec9-95ff-50acbf609ff5"
312-
request_option = TSC.ExcelRequestOptions(maxage=1)
313-
request_option.vf("stuff", "1")
314-
self.server.views.populate_excel(single_view, request_option)
315-
316-
excel_file = b"".join(single_view.excel)
317-
self.assertEqual(response, excel_file)

0 commit comments

Comments
 (0)