How to use tableauserverclient - 10 common examples

To help you get started, we’ve selected a few tableauserverclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tableau / server-client-python / test / test_metadata.py View on Github external
def setUp(self):
        self.server = TSC.Server('http://test')
        self.baseurl = self.server.metadata.baseurl
        self.server.version = "3.2"

        self.server._site_id = 'dad65087-b08b-4603-af4e-2887b8aafc67'
        self.server._auth_token = 'j80k54ll2lfMZ0tv97mlPvvSCRyD0DOM'
github tableau / server-client-python / test / test_view.py View on Github external
def setUp(self):
        self.server = TSC.Server('http://test')
        self.server.version = '2.7'

        # Fake sign in
        self.server._site_id = 'dad65087-b08b-4603-af4e-2887b8aafc67'
        self.server._auth_token = 'j80k54ll2lfMZ0tv97mlPvvSCRyD0DOM'

        self.baseurl = self.server.views.baseurl
        self.siteurl = self.server.views.siteurl
github tableau / server-client-python / test / test_server_info.py View on Github external
def setUp(self):
        self.server = TSC.Server('http://test')
        self.baseurl = self.server.server_info.baseurl
        self.server.version = "2.4"
github tableau / server-client-python / test / test_auth.py View on Github external
def test_sign_in_impersonate(self):
        with open(SIGN_IN_IMPERSONATE_XML, 'rb') as f:
            response_xml = f.read().decode('utf-8')
        with requests_mock.mock() as m:
            m.post(self.baseurl + '/signin', text=response_xml)
            tableau_auth = TSC.TableauAuth('testuser', 'password',
                                           user_id_to_impersonate='dd2239f6-ddf1-4107-981a-4cf94e415794')
            self.server.auth.sign_in(tableau_auth)

        self.assertEqual('MJonFA6HDyy2C3oqR13fRGqE6cmgzwq3', self.server.auth_token)
        self.assertEqual('dad65087-b08b-4603-af4e-2887b8aafc67', self.server.site_id)
        self.assertEqual('dd2239f6-ddf1-4107-981a-4cf94e415794', self.server.user_id)
github tableau / server-client-python / test / test_sort.py View on Github external
def test_filter_equals(self):
        with requests_mock.mock() as m:
            m.get(requests_mock.ANY)
            url = "http://test/api/2.3/sites/dad65087-b08b-4603-af4e-2887b8aafc67/workbooks"
            opts = TSC.RequestOptions(pagesize=13, pagenumber=13)
            opts.filter.add(TSC.Filter(TSC.RequestOptions.Field.Name,
                                       TSC.RequestOptions.Operator.Equals,
                                       'Superstore'))

            resp = self.server.workbooks._make_request(requests.get,
                                                       url,
                                                       content=None,
                                                       request_object=opts,
                                                       auth_token='j80k54ll2lfMZ0tv97mlPvvSCRyD0DOM',
                                                       content_type='text/xml')

            self.assertEqual(resp.request.query, 'pagenumber=13&pagesize=13&filter=name:eq:superstore')
github tableau / server-client-python / test / test_sort.py View on Github external
def test_filter_combo(self):
        with requests_mock.mock() as m:
            m.get(requests_mock.ANY)
            url = "http://test/api/2.3/sites/dad65087-b08b-4603-af4e-2887b8aafc67/users"
            opts = TSC.RequestOptions(pagesize=13, pagenumber=13)

            opts.filter.add(TSC.Filter(TSC.RequestOptions.Field.LastLogin,
                                       TSC.RequestOptions.Operator.GreaterThanOrEqual,
                                       '2017-01-15T00:00:00:00Z'))

            opts.filter.add(TSC.Filter(TSC.RequestOptions.Field.SiteRole,
                                       TSC.RequestOptions.Operator.Equals,
                                       'Publisher'))

            resp = self.server.workbooks._make_request(requests.get,
                                                       url,
                                                       content=None,
                                                       request_object=opts,
                                                       auth_token='j80k54ll2lfMZ0tv97mlPvvSCRyD0DOM',
                                                       content_type='text/xml')
github tableau / server-client-python / test / test_pager.py View on Github external
m.get(self.baseurl + "?pageNumber=2&pageSize=1", text=page_2)
            m.get(self.baseurl + "?pageNumber=3&pageSize=1", text=page_3)
            m.get(self.baseurl + "?pageNumber=1&pageSize=3", text=page_1)

            # Starting on page 2 should get 2 out of 3
            opts = TSC.RequestOptions(2, 1)
            workbooks = list(TSC.Pager(self.server.workbooks, opts))
            self.assertTrue(len(workbooks) == 2)

            # Check that the workbooks are the 2 we think they should be
            wb2, wb3 = workbooks
            self.assertEqual(wb2.name, 'Page2Workbook')
            self.assertEqual(wb3.name, 'Page3Workbook')

            # Starting on 1 with pagesize of 3 should get all 3
            opts = TSC.RequestOptions(1, 3)
            workbooks = list(TSC.Pager(self.server.workbooks, opts))
            self.assertTrue(len(workbooks) == 3)
            wb1, wb2, wb3 = workbooks
            self.assertEqual(wb1.name, 'Page1Workbook')
            self.assertEqual(wb2.name, 'Page2Workbook')
            self.assertEqual(wb3.name, 'Page3Workbook')

            # Starting on 3 with pagesize of 1 should get the last item
            opts = TSC.RequestOptions(3, 1)
            workbooks = list(TSC.Pager(self.server.workbooks, opts))
            self.assertTrue(len(workbooks) == 1)
            # Should have the last workbook
            wb3 = workbooks.pop()
            self.assertEqual(wb3.name, 'Page3Workbook')
github tableau / server-client-python / test / test_request_option.py View on Github external
def test_page_size(self):
        with open(PAGE_SIZE_XML, 'rb') as f:
            response_xml = f.read().decode('utf-8')
        with requests_mock.mock() as m:
            m.get(self.baseurl + '/views?pageSize=5', text=response_xml)
            req_option = TSC.RequestOptions().page_size(5)
            all_views, pagination_item = self.server.views.get(req_option)

        self.assertEqual(1, pagination_item.page_number)
        self.assertEqual(5, pagination_item.page_size)
        self.assertEqual(33, pagination_item.total_available)
        self.assertEqual(5, len(all_views))
github tableau / server-client-python / test / test_pager.py View on Github external
with open(GET_XML_PAGE1, 'rb') as f:
            page_1 = f.read().decode('utf-8')
        with open(GET_XML_PAGE2, 'rb') as f:
            page_2 = f.read().decode('utf-8')
        with open(GET_XML_PAGE3, 'rb') as f:
            page_3 = f.read().decode('utf-8')
        with requests_mock.mock() as m:
            # Register Pager with some pages
            m.get(self.baseurl + "?pageNumber=1&pageSize=1", text=page_1)
            m.get(self.baseurl + "?pageNumber=2&pageSize=1", text=page_2)
            m.get(self.baseurl + "?pageNumber=3&pageSize=1", text=page_3)
            m.get(self.baseurl + "?pageNumber=1&pageSize=3", text=page_1)

            # Starting on page 2 should get 2 out of 3
            opts = TSC.RequestOptions(2, 1)
            workbooks = list(TSC.Pager(self.server.workbooks, opts))
            self.assertTrue(len(workbooks) == 2)

            # Check that the workbooks are the 2 we think they should be
            wb2, wb3 = workbooks
            self.assertEqual(wb2.name, 'Page2Workbook')
            self.assertEqual(wb3.name, 'Page3Workbook')

            # Starting on 1 with pagesize of 3 should get all 3
            opts = TSC.RequestOptions(1, 3)
            workbooks = list(TSC.Pager(self.server.workbooks, opts))
            self.assertTrue(len(workbooks) == 3)
            wb1, wb2, wb3 = workbooks
            self.assertEqual(wb1.name, 'Page1Workbook')
            self.assertEqual(wb2.name, 'Page2Workbook')
            self.assertEqual(wb3.name, 'Page3Workbook')
github tableau / server-client-python / test / test_pager.py View on Github external
page_1 = f.read().decode('utf-8')
        with open(GET_XML_PAGE2, 'rb') as f:
            page_2 = f.read().decode('utf-8')
        with open(GET_XML_PAGE3, 'rb') as f:
            page_3 = f.read().decode('utf-8')
        with requests_mock.mock() as m:
            # Register Pager with default request options
            m.get(self.baseurl, text=page_1)

            # Register Pager with some pages
            m.get(self.baseurl + "?pageNumber=1&pageSize=1", text=page_1)
            m.get(self.baseurl + "?pageNumber=2&pageSize=1", text=page_2)
            m.get(self.baseurl + "?pageNumber=3&pageSize=1", text=page_3)

            # No options should get all 3
            workbooks = list(TSC.Pager(self.server.workbooks))
            self.assertTrue(len(workbooks) == 3)

            # Let's check that workbook items aren't duplicates
            wb1, wb2, wb3 = workbooks
            self.assertEqual(wb1.name, 'Page1Workbook')
            self.assertEqual(wb2.name, 'Page2Workbook')
            self.assertEqual(wb3.name, 'Page3Workbook')