Skip to content

Commit 3e849a9

Browse files
committed
chore: workook tests converted to pytest
1 parent 9b84601 commit 3e849a9

File tree

2 files changed

+321
-282
lines changed

2 files changed

+321
-282
lines changed

tableauserverclient/server/endpoint/workbooks_endpoint.py

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@
3030
from tableauserverclient.server import RequestFactory
3131

3232
from typing import (
33+
Literal,
3334
Optional,
3435
TYPE_CHECKING,
36+
TypeVar,
3537
Union,
38+
overload,
3639
)
3740
from collections.abc import Iterable, Sequence
3841

@@ -383,16 +386,33 @@ def update_connections(
383386
logger.info(f"Updated connections for workbook {workbook_item.id}: {', '.join(updated_ids)}")
384387
return connection_items
385388

389+
T = TypeVar("T", bound=FileObjectW)
390+
@overload
391+
def download(
392+
self,
393+
workbook_id: str,
394+
filepath: T,
395+
include_extract: bool = True,
396+
) -> T: ...
397+
398+
@overload
399+
def download(
400+
self,
401+
workbook_id: str,
402+
filepath: Optional[FilePath] = None,
403+
include_extract: bool = True,
404+
) -> str: ...
405+
386406
# Download workbook contents with option of passing in filepath
387407
@api(version="2.0")
388408
@parameter_added_in(no_extract="2.5")
389409
@parameter_added_in(include_extract="2.5")
390410
def download(
391411
self,
392-
workbook_id: str,
393-
filepath: Optional[PathOrFileW] = None,
394-
include_extract: bool = True,
395-
) -> PathOrFileW:
412+
workbook_id,
413+
filepath=None,
414+
include_extract=True,
415+
):
396416
"""
397417
Downloads a workbook to the specified directory (optional).
398418
@@ -741,6 +761,28 @@ def delete_permission(self, item: WorkbookItem, capability_item: PermissionsRule
741761
"""
742762
return self._permissions.delete(item, capability_item)
743763

764+
@overload
765+
def publish(self,
766+
workbook_item: WorkbookItem,
767+
file: PathOrFileR,
768+
mode: str,
769+
connections: Optional[Sequence[ConnectionItem]],
770+
as_job: Literal[False],
771+
skip_connection_check: bool,
772+
parameters=None,
773+
) -> WorkbookItem: ...
774+
775+
@overload
776+
def publish(self,
777+
workbook_item: WorkbookItem,
778+
file: PathOrFileR,
779+
mode: str,
780+
connections: Optional[Sequence[ConnectionItem]],
781+
as_job: Literal[True],
782+
skip_connection_check: bool,
783+
parameters=None,
784+
) -> JobItem: ...
785+
744786
@api(version="2.0")
745787
@parameter_added_in(as_job="3.0")
746788
@parameter_added_in(connections="2.8")
@@ -977,15 +1019,25 @@ def _get_workbook_revisions(
9771019
revisions = RevisionItem.from_response(server_response.content, self.parent_srv.namespace, workbook_item)
9781020
return revisions
9791021

1022+
@overload
1023+
def download_revision(
1024+
self, workbook_id: str, revision_number: Optional[str], filepath: FileObjectW, include_extract: bool
1025+
) -> FileObjectW: ...
1026+
1027+
@overload
1028+
def download_revision(
1029+
self, workbook_id: str, revision_number: Optional[str], filepath: Optional[FilePath], include_extract: bool
1030+
) -> str: ...
1031+
9801032
# Download 1 workbook revision by revision number
9811033
@api(version="2.3")
9821034
def download_revision(
9831035
self,
984-
workbook_id: str,
985-
revision_number: Optional[str],
986-
filepath: Optional[PathOrFileW] = None,
987-
include_extract: bool = True,
988-
) -> PathOrFileW:
1036+
workbook_id,
1037+
revision_number,
1038+
filepath,
1039+
include_extract=True,
1040+
):
9891041
"""
9901042
Downloads a workbook revision to the specified directory (optional).
9911043

0 commit comments

Comments
 (0)