Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions tableauserverclient/server/request_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _append_view_filters(self, params):


class CSVRequestOptions(_FilterOptionsBase):
def __init__(self, maxage=None):
def __init__(self, maxage=-1):
super(CSVRequestOptions, self).__init__()
self.max_age = maxage

Expand All @@ -112,13 +112,13 @@ def max_age(self):
return self._max_age

@max_age.setter
@property_is_int(range=(0, 240))
@property_is_int(range=(0, 240), allowed=[-1])
def max_age(self, value):
self._max_age = value

def apply_query_params(self, url):
params = []
if self.max_age != 0:
if self.max_age != -1:
params.append('maxAge={0}'.format(self.max_age))

self._append_view_filters(params)
Expand All @@ -130,7 +130,7 @@ class ImageRequestOptions(_FilterOptionsBase):
class Resolution:
High = 'high'

def __init__(self, imageresolution=None, maxage=None):
def __init__(self, imageresolution=None, maxage=-1):
super(ImageRequestOptions, self).__init__()
self.image_resolution = imageresolution
self.max_age = maxage
Expand All @@ -140,15 +140,15 @@ def max_age(self):
return self._max_age

@max_age.setter
@property_is_int(range=(0, 240))
@property_is_int(range=(0, 240), allowed=[-1])
def max_age(self, value):
self._max_age = value

def apply_query_params(self, url):
params = []
if self.image_resolution:
params.append('resolution={0}'.format(self.image_resolution))
if self.max_age != 0:
if self.max_age != -1:
params.append('maxAge={0}'.format(self.max_age))

self._append_view_filters(params)
Expand Down Expand Up @@ -176,7 +176,7 @@ class Orientation:
Portrait = "portrait"
Landscape = "landscape"

def __init__(self, page_type=None, orientation=None, maxage=0):
def __init__(self, page_type=None, orientation=None, maxage=-1):
super(PDFRequestOptions, self).__init__()
self.page_type = page_type
self.orientation = orientation
Expand All @@ -187,7 +187,7 @@ def max_age(self):
return self._max_age

@max_age.setter
@property_is_int(range=(0, 240))
@property_is_int(range=(0, 240), allowed=[-1])
def max_age(self, value):
self._max_age = value

Expand All @@ -199,7 +199,7 @@ def apply_query_params(self, url):
if self.orientation:
params.append('orientation={0}'.format(self.orientation))

if self.max_age != 0:
if self.max_age != -1:
params.append('maxAge={0}'.format(self.max_age))

self._append_view_filters(params)
Expand Down
12 changes: 12 additions & 0 deletions test/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ def test_populate_csv(self):
csv_file = b"".join(single_view.csv)
self.assertEqual(response, csv_file)

def test_populate_csv_default_maxage(self):
with open(POPULATE_CSV, 'rb') as f:
response = f.read()
with requests_mock.mock() as m:
m.get(self.baseurl + '/d79634e1-6063-4ec9-95ff-50acbf609ff5/data', content=response)
single_view = TSC.ViewItem()
single_view._id = 'd79634e1-6063-4ec9-95ff-50acbf609ff5'
self.server.views.populate_csv(single_view)

csv_file = b"".join(single_view.csv)
self.assertEqual(response, csv_file)

def test_populate_image_missing_id(self):
single_view = TSC.ViewItem()
single_view._id = None
Expand Down