Skip to content

Commit 096ee35

Browse files
jorwoodsjacalata
authored andcommitted
chore: pytestify test_custom_view (#1651)
* chore: pytestify test_custom_view * chore: remove unused import * chore: add server type hints --------- Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
1 parent 5efa1b6 commit 096ee35

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

test/test_custom_view.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,9 @@ def test_update(server: TSC.Server) -> None:
141141
the_custom_view = TSC.CustomViewItem("1d0304cd-3796-429f-b815-7258370b9b74", name="Best test ever")
142142
the_custom_view._id = "1f951daf-4061-451a-9df1-69a8062664f2"
143143
the_custom_view.owner = TSC.UserItem()
144-
assert the_custom_view.owner is not None # for mypy
145144
the_custom_view.owner.id = "dd2239f6-ddf1-4107-981a-4cf94e415794"
146145
the_custom_view = server.custom_views.update(the_custom_view)
147146

148-
assert isinstance(the_custom_view, TSC.CustomViewItem)
149147
assert "1f951daf-4061-451a-9df1-69a8062664f2" == the_custom_view.id
150148
if the_custom_view.owner:
151149
assert "dd2239f6-ddf1-4107-981a-4cf94e415794" == the_custom_view.owner.id
@@ -174,9 +172,8 @@ def test_publish_filepath(server: TSC.Server) -> None:
174172
cv = TSC.CustomViewItem(name="test")
175173
cv._owner = TSC.UserItem()
176174
cv._owner._id = "dd2239f6-ddf1-4107-981a-4cf94e415794"
177-
cv.workbook = TSC.WorkbookItem()
178-
assert cv.workbook is not None
179-
cv.workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
175+
cv._workbook = TSC.WorkbookItem()
176+
cv._workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
180177
with requests_mock.mock() as m:
181178
m.post(server.custom_views.expurl, status_code=201, text=GET_XML.read_text())
182179
view = server.custom_views.publish(cv, CUSTOM_VIEW_DOWNLOAD)
@@ -191,9 +188,8 @@ def test_publish_file_str(server: TSC.Server) -> None:
191188
cv = TSC.CustomViewItem(name="test")
192189
cv._owner = TSC.UserItem()
193190
cv._owner._id = "dd2239f6-ddf1-4107-981a-4cf94e415794"
194-
cv.workbook = TSC.WorkbookItem()
195-
assert cv.workbook is not None
196-
cv.workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
191+
cv._workbook = TSC.WorkbookItem()
192+
cv._workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
197193
with requests_mock.mock() as m:
198194
m.post(server.custom_views.expurl, status_code=201, text=GET_XML.read_text())
199195
view = server.custom_views.publish(cv, str(CUSTOM_VIEW_DOWNLOAD))
@@ -208,9 +204,8 @@ def test_publish_file_io(server: TSC.Server) -> None:
208204
cv = TSC.CustomViewItem(name="test")
209205
cv._owner = TSC.UserItem()
210206
cv._owner._id = "dd2239f6-ddf1-4107-981a-4cf94e415794"
211-
cv.workbook = TSC.WorkbookItem()
212-
assert cv.workbook is not None
213-
cv.workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
207+
cv._workbook = TSC.WorkbookItem()
208+
cv._workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
214209
data = io.BytesIO(CUSTOM_VIEW_DOWNLOAD.read_bytes())
215210
with requests_mock.mock() as m:
216211
m.post(server.custom_views.expurl, status_code=201, text=GET_XML.read_text())
@@ -225,9 +220,8 @@ def test_publish_file_io(server: TSC.Server) -> None:
225220
def test_publish_missing_owner_id(server: TSC.Server) -> None:
226221
cv = TSC.CustomViewItem(name="test")
227222
cv._owner = TSC.UserItem()
228-
cv.workbook = TSC.WorkbookItem()
229-
assert cv.workbook is not None
230-
cv.workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
223+
cv._workbook = TSC.WorkbookItem()
224+
cv._workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
231225
with requests_mock.mock() as m:
232226
m.post(server.custom_views.expurl, status_code=201, text=GET_XML.read_text())
233227
with pytest.raises(ValueError):
@@ -238,7 +232,7 @@ def test_publish_missing_wb_id(server: TSC.Server) -> None:
238232
cv = TSC.CustomViewItem(name="test")
239233
cv._owner = TSC.UserItem()
240234
cv._owner._id = "dd2239f6-ddf1-4107-981a-4cf94e415794"
241-
cv.workbook = TSC.WorkbookItem()
235+
cv._workbook = TSC.WorkbookItem()
242236
with requests_mock.mock() as m:
243237
m.post(server.custom_views.expurl, status_code=201, text=GET_XML.read_text())
244238
with pytest.raises(ValueError):
@@ -249,9 +243,8 @@ def test_large_publish(server: TSC.Server):
249243
cv = TSC.CustomViewItem(name="test")
250244
cv._owner = TSC.UserItem()
251245
cv._owner._id = "dd2239f6-ddf1-4107-981a-4cf94e415794"
252-
cv.workbook = TSC.WorkbookItem()
253-
assert cv.workbook is not None
254-
cv.workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
246+
cv._workbook = TSC.WorkbookItem()
247+
cv._workbook._id = "1f951daf-4061-451a-9df1-69a8062664f2"
255248
with ExitStack() as stack:
256249
temp_dir = stack.enter_context(TemporaryDirectory())
257250
file_path = Path(temp_dir) / "test_file"

0 commit comments

Comments
 (0)