How to use tabpy - 10 common examples

To help you get started, we’ve selected a few tabpy 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 / TabPy / tests / unit / tools_tests / test_client.py View on Github external
def test_init(self):
        client = Client("http://example.com:9004")

        self.assertEqual(client._endpoint, "http://example.com:9004")

        client = Client("http://example.com/", 10.0)

        self.assertEqual(client._endpoint, "http://example.com/")

        client = Client(endpoint="https://example.com/", query_timeout=-10.0)

        self.assertEqual(client._endpoint, "https://example.com/")
        self.assertEqual(client.query_timeout, 0.0)

        # valid name tests
        with self.assertRaises(ValueError):
            Client("")
        with self.assertRaises(TypeError):
            Client(1.0)
        with self.assertRaises(ValueError):
            Client("*#")
        with self.assertRaises(TypeError):
            Client()
        with self.assertRaises(ValueError):
            Client("http:/www.example.com/")
        with self.assertRaises(ValueError):
github tableau / TabPy / tests / unit / tools_tests / test_client.py View on Github external
def test_init(self):
        client = Client("http://example.com:9004")

        self.assertEqual(client._endpoint, "http://example.com:9004")

        client = Client("http://example.com/", 10.0)

        self.assertEqual(client._endpoint, "http://example.com/")

        client = Client(endpoint="https://example.com/", query_timeout=-10.0)

        self.assertEqual(client._endpoint, "https://example.com/")
        self.assertEqual(client.query_timeout, 0.0)

        # valid name tests
        with self.assertRaises(ValueError):
            Client("")
        with self.assertRaises(TypeError):
github tableau / TabPy / tests / unit / tools_tests / test_client.py View on Github external
def test_init(self):
        client = Client("http://example.com:9004")

        self.assertEqual(client._endpoint, "http://example.com:9004")

        client = Client("http://example.com/", 10.0)

        self.assertEqual(client._endpoint, "http://example.com/")

        client = Client(endpoint="https://example.com/", query_timeout=-10.0)

        self.assertEqual(client._endpoint, "https://example.com/")
        self.assertEqual(client.query_timeout, 0.0)

        # valid name tests
        with self.assertRaises(ValueError):
            Client("")
        with self.assertRaises(TypeError):
            Client(1.0)
        with self.assertRaises(ValueError):
            Client("*#")
        with self.assertRaises(TypeError):
github tableau / TabPy / tests / unit / server_tests / test_service_info_handler.py View on Github external
def get_app(self):
        self.app = TabPyApp()
        return self.app._create_tornado_web_app()
github tableau / TabPy / tests / unit / server_tests / test_config.py View on Github external
mock_path_exists,
        mock_psws,
        mock_management_util,
        mock_tabpy_state,
        mock_parse_arguments,
    ):
        pkg_path = os.path.dirname(tabpy.__file__)
        obj_path = os.path.join(pkg_path, "tmp", "query_objects")
        state_path = os.path.join(pkg_path, "tabpy_server")
        mock_os.environ = {
            "TABPY_PORT": "9004",
            "TABPY_QUERY_OBJECT_PATH": obj_path,
            "TABPY_STATE_PATH": state_path,
        }

        TabPyApp(None)

        self.assertEqual(len(mock_psws.mock_calls), 1)
        self.assertEqual(len(mock_tabpy_state.mock_calls), 1)
        self.assertEqual(len(mock_path_exists.mock_calls), 1)
        self.assertTrue(len(mock_management_util.mock_calls) > 0)
        mock_os.makedirs.assert_not_called()
github tableau / TabPy / tests / unit / server_tests / test_pwd_file.py View on Github external
def test_given_multiple_credentials_expect_all_parsed(self):
        self._set_file(
            self.config_file.name, "[TabPy]\n" f"TABPY_PWD_FILE = {self.pwd_file.name}"
        )
        creds = {"user_1": "pwd_1", "user@2": "pwd@2", "user#3": "pwd#3"}

        pwd_file_context = ""
        for login in creds:
            pwd_file_context += f"{login} {creds[login]}\n"

        self._set_file(self.pwd_file.name, pwd_file_context)
        app = TabPyApp(self.config_file.name)

        self.assertCountEqual(creds, app.credentials)
        for login in creds:
            self.assertIn(login, app.credentials)
            self.assertEqual(creds[login], app.credentials[login])
github tableau / TabPy / tests / unit / server_tests / test_config.py View on Github external
def test_http(self):
        self.fp.write("[TabPy]\n" "TABPY_TRANSFER_PROTOCOL = http")
        self.fp.close()

        app = TabPyApp(self.fp.name)
        self.assertEqual(app.settings["transfer_protocol"], "http")
github tableau / TabPy / tests / unit / server_tests / test_config.py View on Github external
def assertTabPyAppRaisesRuntimeError(self, expected_message):
        with self.assertRaises(RuntimeError) as err:
            TabPyApp(self.fp.name)
        self.assertEqual(err.exception.args[0], expected_message)
github tableau / TabPy / tests / unit / server_tests / test_pwd_file.py View on Github external
def test_given_no_pwd_file_expect_empty_credentials_list(self):
        self._set_file(
            self.config_file.name, "[TabPy]\n" "TABPY_TRANSFER_PROTOCOL = http"
        )

        app = TabPyApp(self.config_file.name)
        self.assertDictEqual(
            app.credentials,
            {},
            "Expected no credentials with no password file provided",
        )