Skip to content

Commit b8e2aba

Browse files
vchavatapalliVineeth Sai Surya Chavatapalli
authored andcommitted
Address reviewer feedback from jorwoods
- Remove unnecessary default=None from argparse optional arguments - Remove unused imports (read_xml_asset, read_xml_assets) from test files - Use Path.read_text() directly instead of helper functions - Keep only 'asset' import for other uses in test files These changes improve code clarity and follow Python best practices.
1 parent f0481fc commit b8e2aba

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

samples/update_connections_auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def main():
2222
# Resource-specific
2323
parser.add_argument("resource_type", choices=["workbook", "datasource"])
2424
parser.add_argument("resource_id")
25-
parser.add_argument("--datasource_username", default=None, help="Datasource username (optional)")
26-
parser.add_argument("--authentication_type", default=None, help="Authentication type (optional)")
27-
parser.add_argument("--datasource_password", default=None, help="Datasource password (optional)")
25+
parser.add_argument("--datasource_username", help="Datasource username (optional)")
26+
parser.add_argument("--authentication_type", help="Authentication type (optional)")
27+
parser.add_argument("--datasource_password", help="Datasource password (optional)")
2828
parser.add_argument(
2929
"--embed_password", default="true", choices=["true", "false"], help="Embed password (default: true)"
3030
)

test/test_datasource.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from tableauserverclient.server.endpoint.exceptions import InternalServerError
1717
from tableauserverclient.server.endpoint.fileuploads_endpoint import Fileuploads
1818
from tableauserverclient.server.request_factory import RequestFactory
19-
from ._utils import asset, read_xml_asset, read_xml_assets
19+
from ._utils import asset
2020

2121
TEST_ASSET_DIR = Path(__file__).parent / "assets"
2222

@@ -162,7 +162,8 @@ def test_update_copy_fields(server) -> None:
162162
assert single_datasource._project_name == updated_datasource._project_name
163163

164164
def test_update_connections(self) -> None:
165-
populate_xml, response_xml = read_xml_assets(POPULATE_CONNECTIONS_XML, UPDATE_CONNECTIONS_XML)
165+
populate_xml = POPULATE_CONNECTIONS_XML.read_text()
166+
response_xml = UPDATE_CONNECTIONS_XML.read_text()
166167

167168
with requests_mock.Mocker() as m:
168169

@@ -201,7 +202,8 @@ def test_update_connections(self) -> None:
201202

202203
def test_update_connections_without_auth_type(self) -> None:
203204
"""Test that update_connections works when authentication_type is not provided."""
204-
populate_xml, response_xml = read_xml_assets(POPULATE_CONNECTIONS_XML, UPDATE_CONNECTIONS_NO_AUTH_XML)
205+
populate_xml = POPULATE_CONNECTIONS_XML.read_text()
206+
response_xml = UPDATE_CONNECTIONS_NO_AUTH_XML.read_text()
205207

206208
with requests_mock.Mocker() as m:
207209

test/test_workbook.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from tableauserverclient.models import UserItem, GroupItem, PermissionsRule
1414
from tableauserverclient.server.endpoint.exceptions import InternalServerError, UnsupportedAttributeError
1515
from tableauserverclient.server.request_factory import RequestFactory
16-
from ._utils import asset, read_xml_asset, read_xml_assets
1716

1817
TEST_ASSET_DIR = Path(__file__).parent / "assets"
1918

@@ -709,7 +708,8 @@ def test_publish_with_thumbnails_user_id(server: TSC.Server) -> None:
709708
assert re.search(b'thumbnailsUserId=\\"ee8c6e70-43b6-11e6-af4f-f7b0d8e20761\\"', request_body)
710709

711710
def test_update_workbook_connections(self) -> None:
712-
populate_xml, response_xml = read_xml_assets(POPULATE_CONNECTIONS_XML, UPDATE_CONNECTIONS_XML)
711+
populate_xml = POPULATE_CONNECTIONS_XML.read_text()
712+
response_xml = UPDATE_CONNECTIONS_XML.read_text()
713713

714714
with requests_mock.Mocker() as m:
715715
workbook_id = "1a2b3c4d-5e6f-7a8b-9c0d-112233445566"
@@ -742,7 +742,8 @@ def test_update_workbook_connections(self) -> None:
742742

743743
def test_update_workbook_connections_without_auth_type(self) -> None:
744744
"""Test that update_connections works when authentication_type is not provided."""
745-
populate_xml, response_xml = read_xml_assets(POPULATE_CONNECTIONS_XML, UPDATE_CONNECTIONS_NO_AUTH_XML)
745+
populate_xml = POPULATE_CONNECTIONS_XML.read_text()
746+
response_xml = UPDATE_CONNECTIONS_NO_AUTH_XML.read_text()
746747

747748
with requests_mock.Mocker() as m:
748749
workbook_id = "1a2b3c4d-5e6f-7a8b-9c0d-112233445566"

0 commit comments

Comments
 (0)