def test_convert_dttm(self): dttm = self.get_dttm() self.assertEqual( DrillEngineSpec.convert_dttm("DATE", dttm), "TO_DATE('2019-01-02', 'yyyy-MM-dd')", ) self.assertEqual( DrillEngineSpec.convert_dttm("TIMESTAMP", dttm), "TO_TIMESTAMP('2019-01-02 03:04:05', 'yyyy-MM-dd HH:mm:ss')", )
def test_sadrill_impersonation(app_context: AppContext) -> None: """ Test ``modify_url_for_impersonation`` method when driver == sadrill. The method adds the parameter ``impersonation_target`` to the query string. """ from sqlalchemy.engine.url import URL from superset.db_engine_specs.drill import DrillEngineSpec url = URL("drill+sadrill") username = "******" DrillEngineSpec.modify_url_for_impersonation(url, True, username) assert url.query["impersonation_target"] == username
def test_sadrill_impersonation(app_context: AppContext) -> None: """ Test ``modify_url_for_impersonation`` method when driver == sadrill. The method changes the username of URL Object. """ from sqlalchemy.engine.url import URL from superset.db_engine_specs.drill import DrillEngineSpec url = URL("drill+sadrill") username = "******" DrillEngineSpec.modify_url_for_impersonation(url, True, username) assert url.username == username
def test_invalid_impersonation(app_context: AppContext) -> None: """ Test ``modify_url_for_impersonation`` method when driver == foobar. The method raises an exception because impersonation is not supported for drill+foobar. """ from sqlalchemy.engine.url import URL from superset.db_engine_specs.drill import DrillEngineSpec from superset.db_engine_specs.exceptions import SupersetDBAPIProgrammingError url = URL("drill+foobar") username = "******" with raises(SupersetDBAPIProgrammingError): DrillEngineSpec.modify_url_for_impersonation(url, True, username)
def test_odbc_impersonation(app_context: AppContext) -> None: """ Test ``get_url_for_impersonation`` method when driver == odbc. The method adds the parameter ``DelegationUID`` to the query string. """ from sqlalchemy.engine.url import URL from superset.db_engine_specs.drill import DrillEngineSpec url = URL("drill+odbc") username = "******" url = DrillEngineSpec.get_url_for_impersonation(url, True, username) assert url.query["DelegationUID"] == username
def test_jdbc_impersonation() -> None: """ Test ``get_url_for_impersonation`` method when driver == jdbc. The method adds the parameter ``impersonation_target`` to the query string. """ from sqlalchemy.engine.url import URL from superset.db_engine_specs.drill import DrillEngineSpec url = URL("drill+jdbc") username = "******" url = DrillEngineSpec.get_url_for_impersonation(url, True, username) assert url.query["impersonation_target"] == username