From 8df6a779010a80cb0a9959bf022f862ec449a886 Mon Sep 17 00:00:00 2001 From: shinchris Date: Mon, 12 Sep 2016 13:06:16 -0700 Subject: [PATCH] reversed the order of return variables for all .get() calls --- README.md | 2 +- samples/explore_datasource.py | 4 ++-- samples/explore_workbook.py | 4 ++-- samples/move_workbook_projects.py | 4 ++-- samples/move_workbook_sites.py | 2 +- samples/publish_workbook.py | 2 +- samples/set_http_options.py | 4 ++-- .../server/endpoint/datasources_endpoint.py | 2 +- tableauserverclient/server/endpoint/endpoint.py | 9 ++++++--- tableauserverclient/server/endpoint/groups_endpoint.py | 2 +- .../server/endpoint/projects_endpoint.py | 2 +- tableauserverclient/server/endpoint/sites_endpoint.py | 2 +- tableauserverclient/server/endpoint/users_endpoint.py | 2 +- tableauserverclient/server/endpoint/views_endpoint.py | 2 +- .../server/endpoint/workbooks_endpoint.py | 2 +- test/test_datasource.py | 4 ++-- test/test_group.py | 2 +- test/test_project.py | 2 +- test/test_request_option.py | 10 +++++----- test/test_site.py | 2 +- test/test_user.py | 4 ++-- test/test_view.py | 2 +- test/test_workbook.py | 4 ++-- 23 files changed, 39 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 4e1ea4b88..2197b2adc 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ tableau_auth = tableauserverclient.TableauAuth('USERNAME', 'PASSWORD') server = tableauserverclient.Server('SERVER') with server.auth.sign_in(tableau_auth): - pagination_info, all_workbooks = server.workbooks.get() + all_workbooks, pagination_item = server.workbooks.get() ``` ###Server Client Samples diff --git a/samples/explore_datasource.py b/samples/explore_datasource.py index 6b4d2e04f..434cadd3b 100644 --- a/samples/explore_datasource.py +++ b/samples/explore_datasource.py @@ -36,7 +36,7 @@ server = TSC.Server(args.server) with server.auth.sign_in(tableau_auth): # Query projects for use when demonstrating publishing and updating - pagination_item, all_projects = server.projects.get() + all_projects, pagination_item = server.projects.get() default_project = next((project for project in all_projects if project.is_default()), None) # Publish datasource if publish flag is set (-publish, -p) @@ -49,7 +49,7 @@ print("Publish failed. Could not find the default project.") # Gets all datasource items - pagination_item, all_datasources = server.datasources.get() + all_datasources, pagination_item = server.datasources.get() print("\nThere are {} datasources on site: ".format(pagination_item.total_available)) print([datasource.name for datasource in all_datasources]) diff --git a/samples/explore_workbook.py b/samples/explore_workbook.py index 3e5e2efc5..93897388e 100644 --- a/samples/explore_workbook.py +++ b/samples/explore_workbook.py @@ -40,7 +40,7 @@ # Publish workbook if publish flag is set (-publish, -p) if args.publish: - pagination_info, all_projects = server.projects.get() + all_projects, pagination_item = server.projects.get() default_project = next((project for project in all_projects if project.is_default()), None) if default_project is not None: @@ -51,7 +51,7 @@ print('Publish failed. Could not find the default project.') # Gets all workbook items - pagination_item, all_workbooks = server.workbooks.get() + all_workbooks, pagination_item = server.workbooks.get() print("\nThere are {} workbooks on site: ".format(pagination_item.total_available)) print([workbook.name for workbook in all_workbooks]) diff --git a/samples/move_workbook_projects.py b/samples/move_workbook_projects.py index c1be72440..5e7835e72 100644 --- a/samples/move_workbook_projects.py +++ b/samples/move_workbook_projects.py @@ -35,10 +35,10 @@ req_option = TSC.RequestOptions() req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Operator.Equals, args.workbook_name)) - pagination_info, all_workbooks = server.workbooks.get(req_option) + all_workbooks, pagination_item = server.workbooks.get(req_option) # Step 3: Find destination project - pagination_info, all_projects = server.projects.get() + all_projects, pagination_item = server.projects.get() dest_project = next((project for project in all_projects if project.name == args.destination_project), None) if dest_project is not None: diff --git a/samples/move_workbook_sites.py b/samples/move_workbook_sites.py index 51ccebb3c..13103f82e 100644 --- a/samples/move_workbook_sites.py +++ b/samples/move_workbook_sites.py @@ -42,7 +42,7 @@ req_option = TSC.RequestOptions() req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Operator.Equals, args.workbook_name)) - pagination_info, all_workbooks = source_server.workbooks.get(req_option) + all_workbooks, pagination_item = source_server.workbooks.get(req_option) # Step 3: Download workbook to a temp directory if len(all_workbooks) == 0: diff --git a/samples/publish_workbook.py b/samples/publish_workbook.py index fb92e72ca..266cd1b2e 100644 --- a/samples/publish_workbook.py +++ b/samples/publish_workbook.py @@ -39,7 +39,7 @@ with server.auth.sign_in(tableau_auth): # Step 2: Get all the projects on server, then look for the default one. - pagination_info, all_projects = server.projects.get() + all_projects, pagination_item = server.projects.get() default_project = next((project for project in all_projects if project.is_default()), None) # Step 3: If default project is found, form a new workbook item and publish. diff --git a/samples/set_http_options.py b/samples/set_http_options.py index 2091f00f9..6700efb3e 100644 --- a/samples/set_http_options.py +++ b/samples/set_http_options.py @@ -36,7 +36,7 @@ with server.auth.sign_in(tableau_auth): # Step 3: Query all workbooks and list them - pagination_info, all_workbooks = server.workbooks.get() - print('{0} workbooks found. Showing {1}:'.format(pagination_info.total_available, pagination_info.page_size)) + all_workbooks, pagination_item = server.workbooks.get() + print('{0} workbooks found. Showing {1}:'.format(pagination_item.total_available, pagination_item.page_size)) for workbook in all_workbooks: print('\t{0} (ID: {1})'.format(workbook.name, workbook.id)) diff --git a/tableauserverclient/server/endpoint/datasources_endpoint.py b/tableauserverclient/server/endpoint/datasources_endpoint.py index 18a80440f..768a85745 100644 --- a/tableauserverclient/server/endpoint/datasources_endpoint.py +++ b/tableauserverclient/server/endpoint/datasources_endpoint.py @@ -31,7 +31,7 @@ def get(self, req_options=None): server_response = self.get_request(url, req_options) pagination_item = PaginationItem.from_response(server_response.content) all_datasource_items = DatasourceItem.from_response(server_response.content) - return pagination_item, all_datasource_items + return all_datasource_items, pagination_item # Get 1 datasource by id def get_by_id(self, datasource_id): diff --git a/tableauserverclient/server/endpoint/endpoint.py b/tableauserverclient/server/endpoint/endpoint.py index 9ed07c49f..98f451211 100644 --- a/tableauserverclient/server/endpoint/endpoint.py +++ b/tableauserverclient/server/endpoint/endpoint.py @@ -24,7 +24,8 @@ def get_request(self, url, request_object=None): **self.parent_srv.http_options) self._check_status(server_response) if server_response.encoding: - logger.debug(u'Server response from {0}: \n\t{1}'.format(url, server_response.content.decode(server_response.encoding))) + logger.debug(u'Server response from {0}: \n\t{1}'.format( + url, server_response.content.decode(server_response.encoding))) return server_response def delete_request(self, url): @@ -42,7 +43,8 @@ def put_request(self, url, xml_request, content_type='text/xml'): **self.parent_srv.http_options) self._check_status(server_response) if server_response.encoding: - logger.debug(u'Server response from {0}: \n\t{1}'.format(url, server_response.content.decode(server_response.encoding))) + logger.debug(u'Server response from {0}: \n\t{1}'.format( + url, server_response.content.decode(server_response.encoding))) return server_response def post_request(self, url, xml_request, content_type='text/xml'): @@ -53,5 +55,6 @@ def post_request(self, url, xml_request, content_type='text/xml'): **self.parent_srv.http_options) self._check_status(server_response) if server_response.encoding: - logger.debug(u'Server response from {0}: \n\t{1}'.format(url, server_response.content.decode(server_response.encoding))) + logger.debug(u'Server response from {0}: \n\t{1}'.format( + url, server_response.content.decode(server_response.encoding))) return server_response diff --git a/tableauserverclient/server/endpoint/groups_endpoint.py b/tableauserverclient/server/endpoint/groups_endpoint.py index 36024c49b..9e327cdac 100644 --- a/tableauserverclient/server/endpoint/groups_endpoint.py +++ b/tableauserverclient/server/endpoint/groups_endpoint.py @@ -22,7 +22,7 @@ def get(self, req_options=None): server_response = self.get_request(url, req_options) pagination_item = PaginationItem.from_response(server_response.content) all_group_items = GroupItem.from_response(server_response.content) - return pagination_item, all_group_items + return all_group_items, pagination_item # Gets all users in a given group def populate_users(self, group_item, req_options=None): diff --git a/tableauserverclient/server/endpoint/projects_endpoint.py b/tableauserverclient/server/endpoint/projects_endpoint.py index 35972d71b..ea56650f3 100644 --- a/tableauserverclient/server/endpoint/projects_endpoint.py +++ b/tableauserverclient/server/endpoint/projects_endpoint.py @@ -22,7 +22,7 @@ def get(self, req_options=None): server_response = self.get_request(url, req_options) pagination_item = PaginationItem.from_response(server_response.content) all_project_items = ProjectItem.from_response(server_response.content) - return pagination_item, all_project_items + return all_project_items, pagination_item def delete(self, project_id): if not project_id: diff --git a/tableauserverclient/server/endpoint/sites_endpoint.py b/tableauserverclient/server/endpoint/sites_endpoint.py index 7f20e4f1a..cd45014ae 100644 --- a/tableauserverclient/server/endpoint/sites_endpoint.py +++ b/tableauserverclient/server/endpoint/sites_endpoint.py @@ -23,7 +23,7 @@ def get(self, req_options=None): server_response = self.get_request(url, req_options) pagination_item = PaginationItem.from_response(server_response.content) all_site_items = SiteItem.from_response(server_response.content) - return pagination_item, all_site_items + return all_site_items, pagination_item # Gets 1 site by id def get_by_id(self, site_id): diff --git a/tableauserverclient/server/endpoint/users_endpoint.py b/tableauserverclient/server/endpoint/users_endpoint.py index 230ceca35..3ae5d6bac 100644 --- a/tableauserverclient/server/endpoint/users_endpoint.py +++ b/tableauserverclient/server/endpoint/users_endpoint.py @@ -23,7 +23,7 @@ def get(self, req_options=None): server_response = self.get_request(url, req_options) pagination_item = PaginationItem.from_response(server_response.content) all_user_items = UserItem.from_response(server_response.content) - return pagination_item, all_user_items + return all_user_items, pagination_item # Gets 1 user by id def get_by_id(self, user_id): diff --git a/tableauserverclient/server/endpoint/views_endpoint.py b/tableauserverclient/server/endpoint/views_endpoint.py index 7994f7b5d..5fde5f500 100644 --- a/tableauserverclient/server/endpoint/views_endpoint.py +++ b/tableauserverclient/server/endpoint/views_endpoint.py @@ -21,7 +21,7 @@ def get(self, req_options=None): server_response = self.get_request(url, req_options) pagination_item = PaginationItem.from_response(server_response.content) all_view_items = ViewItem.from_response(server_response.content) - return pagination_item, all_view_items + return all_view_items, pagination_item def populate_preview_image(self, view_item): if not view_item.id or not view_item.workbook_id: diff --git a/tableauserverclient/server/endpoint/workbooks_endpoint.py b/tableauserverclient/server/endpoint/workbooks_endpoint.py index 6d02aae79..7ef6f6d98 100644 --- a/tableauserverclient/server/endpoint/workbooks_endpoint.py +++ b/tableauserverclient/server/endpoint/workbooks_endpoint.py @@ -44,7 +44,7 @@ def get(self, req_options=None): server_response = self.get_request(url, req_options) pagination_item = PaginationItem.from_response(server_response.content) all_workbook_items = WorkbookItem.from_response(server_response.content) - return pagination_item, all_workbook_items + return all_workbook_items, pagination_item # Get 1 workbook def get_by_id(self, workbook_id): diff --git a/test/test_datasource.py b/test/test_datasource.py index 72d64be51..c85440b4d 100644 --- a/test/test_datasource.py +++ b/test/test_datasource.py @@ -27,7 +27,7 @@ def test_get(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl, text=response_xml) - pagination_item, all_datasources = self.server.datasources.get() + all_datasources, pagination_item = self.server.datasources.get() self.assertEqual(2, pagination_item.total_available) self.assertEqual('e76a1461-3b1d-4588-bf1b-17551a879ad9', all_datasources[0].id) @@ -60,7 +60,7 @@ def test_get_empty(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl, text=response_xml) - pagination_item, all_datasources = self.server.datasources.get() + all_datasources, pagination_item = self.server.datasources.get() self.assertEqual(0, pagination_item.total_available) self.assertEqual([], all_datasources) diff --git a/test/test_group.py b/test/test_group.py index d61717923..8ad4627af 100644 --- a/test/test_group.py +++ b/test/test_group.py @@ -25,7 +25,7 @@ def test_get(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl, text=response_xml) - pagination_item, all_groups = self.server.groups.get() + all_groups, pagination_item = self.server.groups.get() self.assertEqual(3, pagination_item.total_available) self.assertEqual('ef8b19c0-43b6-11e6-af50-63f5805dbe3c', all_groups[0].id) diff --git a/test/test_project.py b/test/test_project.py index 5374797c1..e7439e96f 100644 --- a/test/test_project.py +++ b/test/test_project.py @@ -25,7 +25,7 @@ def test_get(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl, text=response_xml) - pagination_item, all_projects = self.server.projects.get() + all_projects, pagination_item = self.server.projects.get() self.assertEqual(2, pagination_item.total_available) self.assertEqual('ee8c6e70-43b6-11e6-af4f-f7b0d8e20760', all_projects[0].id) diff --git a/test/test_request_option.py b/test/test_request_option.py index efb92440b..c5dd76805 100644 --- a/test/test_request_option.py +++ b/test/test_request_option.py @@ -28,7 +28,7 @@ def test_pagination(self): with requests_mock.mock() as m: m.get(self.baseurl + '/views?pageNumber=1&pageSize=10', text=response_xml) req_option = TSC.RequestOptions().page_size(10) - pagination_item, all_views = self.server.views.get(req_option) + all_views, pagination_item = self.server.views.get(req_option) self.assertEqual(1, pagination_item.page_number) self.assertEqual(10, pagination_item.page_size) @@ -41,7 +41,7 @@ def test_page_number(self): with requests_mock.mock() as m: m.get(self.baseurl + '/views?pageNumber=3', text=response_xml) req_option = TSC.RequestOptions().page_number(3) - pagination_item, all_views = self.server.views.get(req_option) + all_views, pagination_item = self.server.views.get(req_option) self.assertEqual(3, pagination_item.page_number) self.assertEqual(100, pagination_item.page_size) @@ -54,7 +54,7 @@ def test_page_size(self): with requests_mock.mock() as m: m.get(self.baseurl + '/views?pageSize=5', text=response_xml) req_option = TSC.RequestOptions().page_size(5) - pagination_item, all_views = self.server.views.get(req_option) + all_views, pagination_item = self.server.views.get(req_option) self.assertEqual(1, pagination_item.page_number) self.assertEqual(5, pagination_item.page_size) @@ -69,7 +69,7 @@ def test_filter_equals(self): req_option = TSC.RequestOptions() req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name, TSC.RequestOptions.Operator.Equals, 'RESTAPISample')) - pagination_item, matching_workbooks = self.server.workbooks.get(req_option) + matching_workbooks, pagination_item = self.server.workbooks.get(req_option) self.assertEqual(2, pagination_item.total_available) self.assertEqual('RESTAPISample', matching_workbooks[0].name) @@ -83,7 +83,7 @@ def test_filter_tags_in(self): req_option = TSC.RequestOptions() req_option.filter.add(TSC.Filter(TSC.RequestOptions.Field.Tags, TSC.RequestOptions.Operator.In, ['sample', 'safari', 'weather'])) - pagination_item, matching_workbooks = self.server.workbooks.get(req_option) + matching_workbooks, pagination_item = self.server.workbooks.get(req_option) self.assertEqual(3, pagination_item.total_available) self.assertEqual(set(['weather']), matching_workbooks[0].tags) diff --git a/test/test_site.py b/test/test_site.py index b16c58b36..6f675ce94 100644 --- a/test/test_site.py +++ b/test/test_site.py @@ -25,7 +25,7 @@ def test_get(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl, text=response_xml) - pagination_item, all_sites = self.server.sites.get() + all_sites, pagination_item = self.server.sites.get() self.assertEqual(2, pagination_item.total_available) self.assertEqual('dad65087-b08b-4603-af4e-2887b8aafc67', all_sites[0].id) diff --git a/test/test_user.py b/test/test_user.py index 9234e48ee..c45718e14 100644 --- a/test/test_user.py +++ b/test/test_user.py @@ -29,7 +29,7 @@ def test_get(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl, text=response_xml) - pagination_item, all_users = self.server.users.get() + all_users, pagination_item = self.server.users.get() self.assertEqual(2, pagination_item.total_available) self.assertEqual(2, len(all_users)) @@ -50,7 +50,7 @@ def test_get_empty(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl, text=response_xml) - pagination_item, all_users = self.server.users.get() + all_users, pagination_item = self.server.users.get() self.assertEqual(0, pagination_item.total_available) self.assertEqual(set(), all_users) diff --git a/test/test_view.py b/test/test_view.py index a8ff5e99f..fa77a842f 100644 --- a/test/test_view.py +++ b/test/test_view.py @@ -24,7 +24,7 @@ def test_get(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl + '/views', text=response_xml) - pagination_item, all_views = self.server.views.get() + all_views, pagination_item = self.server.views.get() self.assertEqual(2, pagination_item.total_available) self.assertEqual('d79634e1-6063-4ec9-95ff-50acbf609ff5', all_views[0].id) diff --git a/test/test_workbook.py b/test/test_workbook.py index 58a619460..23d28cba0 100644 --- a/test/test_workbook.py +++ b/test/test_workbook.py @@ -31,7 +31,7 @@ def test_get(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl, text=response_xml) - pagination_item, all_workbooks = self.server.workbooks.get() + all_workbooks, pagination_item = self.server.workbooks.get() self.assertEqual(2, pagination_item.total_available) self.assertEqual('6d13b0ca-043d-4d42-8c9d-3f3313ea3a00', all_workbooks[0].id) @@ -66,7 +66,7 @@ def test_get_empty(self): response_xml = f.read().decode('utf-8') with requests_mock.mock() as m: m.get(self.baseurl, text=response_xml) - pagination_item, all_workbooks = self.server.workbooks.get() + all_workbooks, pagination_item = self.server.workbooks.get() self.assertEqual(0, pagination_item.total_available) self.assertEqual([], all_workbooks)