def test_get_extra_params(self): database = Mock() database.extra = json.dumps({}) database.server_cert = None extra = TrinoEngineSpec.get_extra_params(database) expected = {"engine_params": {"connect_args": {}}} self.assertEqual(extra, expected) expected = { "first": 1, "engine_params": {"second": "two", "connect_args": {"third": "three"}}, } database.extra = json.dumps(expected) database.server_cert = None extra = TrinoEngineSpec.get_extra_params(database) self.assertEqual(extra, expected)
def test_get_extra_params_with_server_cert(self, create_ssl_cert_file_func: Mock): database = Mock() database.extra = json.dumps({}) database.server_cert = "TEST_CERT" create_ssl_cert_file_func.return_value = "/path/to/tls.crt" extra = TrinoEngineSpec.get_extra_params(database) connect_args = extra.get("engine_params", {}).get("connect_args", {}) self.assertEqual(connect_args.get("http_scheme"), "https") self.assertEqual(connect_args.get("verify"), "/path/to/tls.crt") create_ssl_cert_file_func.assert_called_once_with(database.server_cert)