Skip to content

Commit fe719c1

Browse files
jorwoodsjacalata
authored andcommitted
chore: pytestify favorites (#1674)
* fix: black ci errors * chore: pytestify favorites --------- Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
1 parent dbb43c4 commit fe719c1

File tree

3 files changed

+10
-35
lines changed

3 files changed

+10
-35
lines changed

pyproject.toml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,8 @@ classifiers = [
3232
repository = "https://github.com/tableau/server-client-python"
3333

3434
[project.optional-dependencies]
35-
test = ["black==24.10", "build", "mypy==1.4", "pytest>=7.0", "pytest-cov", "pytest-subtests",
36-
"pytest-xdist", "requests-mock>=1.0,<2.0", "types-requests>=2.32.4.20250913"]
37-
38-
[tool.setuptools.package-data]
39-
# Only include data for tableauserverclient, not for samples, test, docs
40-
tableauserverclient = ["*"]
41-
42-
[tool.setuptools.packages.find]
43-
where = ["."]
44-
include = ["tableauserverclient*"]
45-
46-
[tool.setuptools.dynamic]
47-
version = {attr = "versioneer.get_version"}
48-
35+
test = ["black==24.8", "build", "mypy==1.4", "pytest>=7.0", "pytest-cov", "pytest-subtests",
36+
"requests-mock>=1.0,<2.0", "types-requests>=2.32.4.20250913"]
4937
[tool.black]
5038
line-length = 120
5139
target-version = ['py39', 'py310', 'py311', 'py312', 'py313']

test/test_datasource.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,8 @@ def test_publish_description(server: TSC.Server) -> None:
895895
ds_elem = body.find(".//datasource")
896896
assert ds_elem is not None
897897
assert ds_elem.attrib["description"] == "Sample description"
898-
898+
899+
899900
def test_get_datasource_no_owner(server: TSC.Server) -> None:
900901
with requests_mock.mock() as m:
901902
m.get(server.datasources.baseurl, text=GET_NO_OWNER.read_text())

test/test_favorites.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import tableauserverclient as TSC
77
from tableauserverclient.datetime_helpers import parse_datetime
8-
from ._utils import read_xml_asset
98

109
TEST_ASSET_DIR = Path(__file__).parent / "assets"
1110

@@ -45,25 +44,12 @@ def test_get(server: TSC.Server, user: TSC.UserItem) -> None:
4544
assert len(user.favorites["projects"]) == 1
4645
assert len(user.favorites["datasources"]) == 1
4746

48-
collection = self.user.favorites["collections"][0]
49-
50-
assert collection.id == "8c57cb8a-d65f-4a32-813e-5a3f86e8f94e"
51-
assert collection.name == "sample collection"
52-
assert collection.description == "description for sample collection"
53-
assert collection.total_item_count == 3
54-
assert collection.permissioned_item_count == 2
55-
assert collection.visibility == "Private"
56-
assert collection.created_at == parse_datetime("2016-08-11T21:22:40Z")
57-
assert collection.updated_at == parse_datetime("2016-08-11T21:34:17Z")
58-
59-
def test_add_favorite_workbook(self) -> None:
60-
response_xml = read_xml_asset(ADD_FAVORITE_WORKBOOK_XML)
61-
workbook = TSC.WorkbookItem("")
62-
workbook._id = "6d13b0ca-043d-4d42-8c9d-3f3313ea3a00"
63-
workbook.name = "Superstore"
64-
with requests_mock.mock() as m:
65-
m.put(f"{self.baseurl}/{self.user.id}", text=response_xml)
66-
self.server.favorites.add_favorite_workbook(self.user, workbook)
47+
workbook = user.favorites["workbooks"][0]
48+
print("favorited: ")
49+
print(workbook)
50+
view = user.favorites["views"][0]
51+
datasource = user.favorites["datasources"][0]
52+
project = user.favorites["projects"][0]
6753

6854
assert workbook.id == "6d13b0ca-043d-4d42-8c9d-3f3313ea3a00"
6955
assert view.id == "d79634e1-6063-4ec9-95ff-50acbf609ff5"

0 commit comments

Comments
 (0)