Skip to content

Commit 80fec44

Browse files
committed
test fixes: add back Path where it was used before
1 parent 2a12c93 commit 80fec44

File tree

11 files changed

+35
-30
lines changed

11 files changed

+35
-30
lines changed

test/test_custom_view.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
CUSTOM_VIEW_UPDATE_XML = xml_asset_path("custom_view_update.xml")
2121
CUSTOM_VIEW_POPULATE_PDF = data_asset_path("populate_pdf.pdf")
2222
CUSTOM_VIEW_POPULATE_CSV = data_asset_path("populate_csv.csv")
23-
CUSTOM_VIEW_DOWNLOAD = xml_asset_path("custom_view_download.json")
24-
FILE_UPLOAD_INIT = xml_asset_path("fileupload_initialize.xml")
25-
FILE_UPLOAD_APPEND = xml_asset_path("fileupload_append.xml")
23+
CUSTOM_VIEW_DOWNLOAD = Path(xml_asset_path("custom_view_download.json"))
24+
FILE_UPLOAD_INIT = Path(xml_asset_path("fileupload_initialize.xml"))
25+
FILE_UPLOAD_APPEND = Path(xml_asset_path("fileupload_append.xml"))
2626

2727

2828
class CustomViewTests(unittest.TestCase):

test/test_database.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def test_update(self):
5555
self.assertEqual("Test", single_database.certification_note)
5656

5757
def test_populate_permissions(self):
58-
with open(asset(POPULATE_PERMISSIONS_XML), "rb") as f:
59-
response_xml = f.read().decode("utf-8")
58+
response_xml = read_xml_asset(POPULATE_PERMISSIONS_XML)
6059
with requests_mock.mock() as m:
6160
m.get(self.baseurl + "/0448d2ed-590d-4fa0-b272-a2a8a24555b5/permissions", text=response_xml)
6261
single_database = TSC.DatabaseItem("test")

test/test_flowtask.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def test_create_flow_task(self):
3737

3838
task = TaskItem(None, "RunFlow", None, schedule_item=monthly_schedule, target=target_item)
3939

40-
with read_xml_asset(GET_XML_CREATE_FLOW_TASK_RESPONSE) as response_xml:
41-
with requests_mock.mock() as m:
42-
m.post(f"{self.baseurl}", text=response_xml)
43-
create_response_content = self.server.flow_tasks.create(task).decode("utf-8")
40+
response_xml = read_xml_asset(GET_XML_CREATE_FLOW_TASK_RESPONSE)
41+
with requests_mock.mock() as m:
42+
m.post(f"{self.baseurl}", text=response_xml)
43+
create_response_content = self.server.flow_tasks.create(task).decode("utf-8")
4444

4545
self.assertTrue("schedule_id" in create_response_content)
4646
self.assertTrue("flow_id" in create_response_content)

test/test_group.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import unittest
22
import requests_mock
33
import tableauserverclient as TSC
4+
from pathlib import Path
45
from tableauserverclient.datetime_helpers import format_datetime
56

67
from test._utils import data_asset_path, read_xml_asset, xml_asset_path
78

89
GET_XML = xml_asset_path("group_get.xml")
9-
GET_XML_ALL_FIELDS = data_asset_path("group_get_all_fields.xml")
10+
GET_XML_ALL_FIELDS = Path(xml_asset_path("group_get_all_fields.xml"))
1011
POPULATE_USERS = xml_asset_path("group_populate_users.xml")
1112
POPULATE_USERS_EMPTY = xml_asset_path("group_populate_users_empty.xml")
1213
ADD_USER = xml_asset_path("group_add_user.xml")
13-
ADD_USERS = data_asset_path("group_add_users.xml")
14+
ADD_USERS = Path(xml_asset_path("group_add_users.xml"))
1415
ADD_USER_POPULATE = xml_asset_path("group_users_added.xml")
1516
CREATE_GROUP = xml_asset_path("group_create.xml")
1617
CREATE_GROUP_AD = xml_asset_path("group_create_ad.xml")
1718
CREATE_GROUP_ASYNC = xml_asset_path("group_create_async.xml")
1819
UPDATE_XML = xml_asset_path("group_update.xml")
19-
UPDATE_ASYNC_XML = data_asset_path("group_update_async.xml")
20+
UPDATE_ASYNC_XML = Path(xml_asset_path("group_update_async.xml"))
2021

2122

2223
class GroupTests(unittest.TestCase):

test/test_groupsets.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import unittest
2-
2+
from pathlib import Path
33
from defusedxml.ElementTree import fromstring
44
import requests_mock
55

@@ -8,10 +8,10 @@
88

99
from test._utils import xml_asset_path
1010

11-
GROUPSET_CREATE = xml_asset_path("groupsets_create.xml")
12-
GROUPSETS_GET = xml_asset_path("groupsets_get.xml")
13-
GROUPSET_GET_BY_ID = xml_asset_path("groupsets_get_by_id.xml")
14-
GROUPSET_UPDATE = xml_asset_path("groupsets_get_by_id.xml")
11+
GROUPSET_CREATE = Path(xml_asset_path("groupsets_create.xml"))
12+
GROUPSETS_GET = Path(xml_asset_path("groupsets_get.xml"))
13+
GROUPSET_GET_BY_ID = Path(xml_asset_path("groupsets_get_by_id.xml"))
14+
GROUPSET_UPDATE = Path(xml_asset_path("groupsets_get_by_id.xml"))
1515

1616

1717
class TestGroupSets(unittest.TestCase):

test/test_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
METADATA_QUERY_SUCCESS = xml_asset_path("metadata_query_success.json")
1111
METADATA_QUERY_ERROR = xml_asset_path("metadata_query_error.json")
12-
EXPECTED_PAGED_DICT = data_asset_path("metadata_query_expected_dict.dict")
12+
EXPECTED_PAGED_DICT = xml_asset_path("metadata_query_expected_dict.dict")
1313

1414
METADATA_PAGE_1 = xml_asset_path("metadata_paged_1.json")
1515
METADATA_PAGE_2 = xml_asset_path("metadata_paged_2.json")

test/test_project.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
UPDATE_XML = xml_asset_path("project_update.xml")
1313
SET_CONTENT_PERMISSIONS_XML = xml_asset_path("project_content_permission.xml")
1414
CREATE_XML = xml_asset_path("project_create.xml")
15-
POPULATE_PERMISSIONS_XML = "project_populate_permissions.xml"
16-
POPULATE_WORKBOOK_DEFAULT_PERMISSIONS_XML = "project_populate_workbook_default_permissions.xml"
17-
UPDATE_DATASOURCE_DEFAULT_PERMISSIONS_XML = "project_update_datasource_default_permissions.xml"
18-
POPULATE_VIRTUALCONNECTION_DEFAULT_PERMISSIONS_XML = "project_populate_virtualconnection_default_permissions.xml"
19-
UPDATE_VIRTUALCONNECTION_DEFAULT_PERMISSIONS_XML = "project_update_virtualconnection_default_permissions.xml"
15+
POPULATE_PERMISSIONS_XML = xml_asset_path("project_populate_permissions.xml")
16+
POPULATE_WORKBOOK_DEFAULT_PERMISSIONS_XML = xml_asset_path("project_populate_workbook_default_permissions.xml")
17+
UPDATE_DATASOURCE_DEFAULT_PERMISSIONS_XML = xml_asset_path("project_update_datasource_default_permissions.xml")
18+
POPULATE_VIRTUALCONNECTION_DEFAULT_PERMISSIONS_XML = xml_asset_path("project_populate_virtualconnection_default_permissions.xml")
19+
UPDATE_VIRTUALCONNECTION_DEFAULT_PERMISSIONS_XML = xml_asset_path("project_update_virtualconnection_default_permissions.xml")
2020

2121

2222
class ProjectTests(unittest.TestCase):

test/test_request_option.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
FILTER_TAGS_IN = xml_asset_path("request_option_filter_tags_in.xml")
1818
FILTER_MULTIPLE = xml_asset_path("request_option_filter_tags_in.xml")
1919
SLICING_QUERYSET = xml_asset_path("request_option_slicing_queryset.xml")
20-
SLICING_QUERYSET_PAGE_1 = xml_asset_path("queryset_slicing_page_1.xml")
21-
SLICING_QUERYSET_PAGE_2 = xml_asset_path("queryset_slicing_page_2.xml")
20+
SLICING_QUERYSET_PAGE_1 = Path(xml_asset_path("queryset_slicing_page_1.xml"))
21+
SLICING_QUERYSET_PAGE_2 = Path(xml_asset_path("queryset_slicing_page_2.xml"))
2222

2323

2424
class RequestOptionTests(unittest.TestCase):

test/test_tagging.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import tableauserverclient as TSC
1010

1111

12+
# This whole suite seems slow. Is there some excessive setup, or something we can pull out into a onetime setup?
1213
@pytest.fixture
1314
def get_server() -> TSC.Server:
1415
server = TSC.Server("http://test", False)
@@ -114,7 +115,10 @@ def make_vconn() -> TSC.VirtualConnectionItem:
114115
["a", "b", "c", "c"],
115116
]
116117

117-
118+
"""
119+
The standalone add and delete tests are redundant with the update tests.
120+
Given that this is low-pri functionality and this test suite is already slow,
121+
let's not run them by default
118122
@pytest.mark.parametrize("endpoint_type, item", *sample_taggable_items)
119123
@pytest.mark.parametrize("tags", sample_tags)
120124
def test_add_tags(get_server, endpoint_type, item, tags) -> None:
@@ -160,6 +164,7 @@ def test_delete_tags(get_server, endpoint_type, item, tags) -> None:
160164
assert len(history) == len(tag_set)
161165
urls = {r.url.split("/")[-1] for r in history}
162166
assert urls == tag_set
167+
"""
163168

164169

165170
@pytest.mark.parametrize("endpoint_type, item", *sample_taggable_items)

test/test_task.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22
from datetime import time
3-
3+
from pathlib import Path
44
import requests_mock
55

66
import tableauserverclient as TSC
@@ -16,8 +16,8 @@
1616
GET_XML_DATAACCELERATION_TASK = xml_asset_path("tasks_with_dataacceleration_task.xml")
1717
GET_XML_RUN_NOW_RESPONSE = xml_asset_path("tasks_run_now_response.xml")
1818
GET_XML_CREATE_TASK_RESPONSE = xml_asset_path("tasks_create_extract_task.xml")
19-
GET_XML_WITHOUT_SCHEDULE = xml_asset_path("tasks_without_schedule.xml")
20-
GET_XML_WITH_INTERVAL = xml_asset_path("tasks_with_interval.xml")
19+
GET_XML_WITHOUT_SCHEDULE = Path(xml_asset_path("tasks_without_schedule.xml"))
20+
GET_XML_WITH_INTERVAL = Path(xml_asset_path("tasks_with_interval.xml"))
2121

2222

2323
class TaskTests(unittest.TestCase):

0 commit comments

Comments
 (0)