added ability to get usage statistics for views#242
added ability to get usage statistics for views#242shinchris merged 7 commits intodevelopmenttableau/server-client-python:developmentfrom
Conversation
| def _get_views_for_workbook(self, workbook_item): | ||
| url = "{0}/{1}/views".format(self.baseurl, workbook_item.id) | ||
| def _get_views_for_workbook(self, workbook_item, usage): | ||
| url = "{0}/{1}/views".format(self.baseurl, workbook_item.id, usage) |
There was a problem hiding this comment.
usage doesn't need to be in the .format
t8y8
left a comment
There was a problem hiding this comment.
🚀
These are two small rename proposals. I don't feel so strongly as to demand them, but might be a good idea.
test/test_view.py
Outdated
| self.assertEqual('6d13b0ca-043d-4d42-8c9d-3f3313ea3a00', all_views[1].workbook_id) | ||
| self.assertEqual('5de011f8-5aa9-4d5b-b991-f462c8dd6bb7', all_views[1].owner_id) | ||
|
|
||
| def test_get_usage(self): |
test/test_workbook.py
Outdated
| self.assertEqual('Interest rates', views_list[2].name) | ||
| self.assertEqual('RESTAPISample/sheets/Interestrates', views_list[2].content_url) | ||
|
|
||
| def test_populate_views_usage(self): |
There was a problem hiding this comment.
test_populate_views_with_usage
|
🚀 |
| server_response = self.get_request(self.baseurl, req_options) | ||
| url = self.baseurl | ||
| if usage: | ||
| url += "?includeUsageStatistics=true" |
There was a problem hiding this comment.
This could lead to the url being ?includeUsageStatistics=true?page=2 if you pass in request options. Can you add a test to check that the url being generated in this case would be ?includeUsageStatistics=true&page=2 ?
You'll probably want to amend request options so that it inspects the url for the existence of ? and then uses an & to append options to the query string.
def apply_query_params(self, url):
params = []
if '?' in url:
url, existing_params = url.split('?')
params.append(existing_params)
if self.page_number:
params.append('pageNumber={0}'.format(self.page_number))
if self.page_size:
params.append('pageSize={0}'.format(self.page_size))
if len(self.sort) > 0:
sort_options = (str(sort_item) for sort_item in self.sort)
ordered_sort_options = sorted(sort_options)
params.append('sort={}'.format(','.join(ordered_sort_options)))
if len(self.filter) > 0:
filter_options = (str(filter_item) for filter_item in self.filter)
ordered_filter_options = sorted(filter_options)
params.append('filter={}'.format(','.join(ordered_filter_options)))
return "{0}?{1}".format(url, '&'.join(params))That works in cases where the url contains an existing parameter, and in cases where the url is normal |
…, and also added test
test/assets/view_get_usage.xml
Outdated
| <pagination pageNumber="1" pageSize="100" totalAvailable="2" /> | ||
| <views> | ||
| <view id="d79634e1-6063-4ec9-95ff-50acbf609ff5" name="ENDANGERED SAFARI" contentUrl="SafariSample/sheets/ENDANGEREDSAFARI"> | ||
| <view id="d79634e1-6063-4ec9-95ff-50acbf609ff5" name="foo" contentUrl="SafariSample/sheets/ENDANGEREDSAFARI"> |
Issue #179.