Skip to content

Commit

Permalink
BI-4817: add oracle dashsql with params test
Browse files Browse the repository at this point in the history
  • Loading branch information
MCPN committed Oct 30, 2023
1 parent a560f14 commit bea2aff
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
import pytest

from dl_api_lib_testing.connector.dashsql_suite import DefaultDashSQLTestSuite
from dl_testing.test_data.sql_queries import DASHSQL_EXAMPLE_PARAMS

from dl_connector_oracle_tests.db.api.base import OracleDashSQLConnectionTest
from dl_connector_oracle_tests.db.config import SUBSELECT_QUERY_FULL
from dl_connector_oracle_tests.db.config import (
QUERY_WITH_PARAMS,
SUBSELECT_QUERY_FULL,
)


class TestOracleDashSQL(OracleDashSQLConnectionTest, DefaultDashSQLTestSuite):
Expand Down Expand Up @@ -86,3 +90,12 @@ async def test_result(self, data_api_lowlevel_aiohttp_client: TestClient, saved_
"genericdatetime",
"genericdatetime",
]

@pytest.mark.asyncio
async def test_result_with_params(self, data_api_lowlevel_aiohttp_client: TestClient, saved_connection_id: str):
await self.get_dashsql_response(
data_api_aio=data_api_lowlevel_aiohttp_client,
conn_id=saved_connection_id,
query=QUERY_WITH_PARAMS,
params=DASHSQL_EXAMPLE_PARAMS,
)
22 changes: 22 additions & 0 deletions lib/dl_connector_oracle/dl_connector_oracle_tests/db/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ class CoreConnectionSettings:
select 6 as num from dual
) sq
"""
QUERY_WITH_PARAMS = r"""
select
'normal '':string''' as v1_normal_string,
'extended:string' || chr(10) || 'with' || chr(10) || 'newlines' as v2_ext_string,
{{some_string}} as v3_param_string,
{{some_integer}} as v4_param_integer,
{{some_float}} as v5_param_float,
{{some_boolean}} as v6_param_boolean,
{{some_other_boolean}} as v7_param_boolean,
{{some_date}} as v8_param_date,
{{some_datetime}} as v9_param_datetime,
{{3xtr4 ше1гd param}} as v10_weird_name,
{{3xtr4 же1гd param}} as v11_weird_name,
case when 1 in (1, 2) then 1 else 0 end as v12_int_in_tst,
case when 1 in {{intvalues}} then 1 else 0 end as v12_int_in,
case when 0 in {{intvalues}} then 1 else 0 end as v13_int_in_2,
case when 'a' in ('z', 'x') then 1 else 0 end as v14_str_in_tst,
case when 'a' in {{strvalues}} then 1 else 0 end as v14_str_in,
case when 'z' in {{strvalues}} then 1 else 0 end as v14_str_in_2,
1 as stuff
FROM dual
"""

_DB_URL = (
f'oracle://datalens:qwerty@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={get_test_container_hostport("db-oracle", fallback_port=51800).host})'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ class TestOracleAsyncConnectionExecutor(
mark_tests_failed={
DefaultAsyncConnectionExecutorTestSuite.test_closing_sql_sessions: "Sessions not closed", # TODO: FIXME
},
)
)

0 comments on commit bea2aff

Please sign in to comment.