5
5
import xml .etree .ElementTree as ET
6
6
7
7
from tableauserverclient .datetime_helpers import format_datetime
8
+ from tableauserverclient .server .endpoint .exceptions import InternalServerError
8
9
from tableauserverclient .server .request_factory import RequestFactory
10
+ from ._utils import asset
9
11
10
12
TEST_ASSET_DIR = os .path .join (os .path .dirname (__file__ ), 'assets' )
11
13
@@ -319,11 +321,11 @@ def test_publish(self):
319
321
show_tabs = False ,
320
322
project_id = 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760' )
321
323
322
- sample_workbok = os .path .join (TEST_ASSET_DIR , 'SampleWB.twbx' )
324
+ sample_workbook = os .path .join (TEST_ASSET_DIR , 'SampleWB.twbx' )
323
325
publish_mode = self .server .PublishMode .CreateNew
324
326
325
327
new_workbook = self .server .workbooks .publish (new_workbook ,
326
- sample_workbok ,
328
+ sample_workbook ,
327
329
publish_mode )
328
330
329
331
self .assertEqual ('a8076ca1-e9d8-495e-bae6-c684dbb55836' , new_workbook .id )
@@ -350,11 +352,11 @@ def test_publish_async(self):
350
352
show_tabs = False ,
351
353
project_id = 'ee8c6e70-43b6-11e6-af4f-f7b0d8e20760' )
352
354
353
- sample_workbok = os .path .join (TEST_ASSET_DIR , 'SampleWB.twbx' )
355
+ sample_workbook = os .path .join (TEST_ASSET_DIR , 'SampleWB.twbx' )
354
356
publish_mode = self .server .PublishMode .CreateNew
355
357
356
358
new_job = self .server .workbooks .publish (new_workbook ,
357
- sample_workbok ,
359
+ sample_workbook ,
358
360
publish_mode ,
359
361
as_job = True )
360
362
@@ -421,3 +423,13 @@ def test_credentials_and_multi_connect_raises_exception(self):
421
423
response = RequestFactory .Workbook ._generate_xml (new_workbook ,
422
424
connection_credentials = connection_creds ,
423
425
connections = [connection1 ])
426
+
427
+ def test_synchronous_publish_timeout_error (self ):
428
+ with requests_mock .mock () as m :
429
+ m .register_uri ('POST' , self .baseurl , status_code = 504 )
430
+
431
+ new_workbook = TSC .WorkbookItem (project_id = '' )
432
+ publish_mode = self .server .PublishMode .CreateNew
433
+
434
+ self .assertRaisesRegexp (InternalServerError , 'Please use asynchronous publishing to avoid timeouts' ,
435
+ self .server .workbooks .publish , new_workbook , asset ('SampleWB.twbx' ), publish_mode )
0 commit comments