def test_get_conn(self): hook = TtuHook(ttu_conn_id='ttu_default_with_all_params') conn_dict = hook.get_conn() self.assertEqual( conn_dict, dict(login='******', password='******', host='localhost_with_all_params', ttu_log_folder='/tmp/', ttu_max_sessions=999, console_output_encoding='latin1', bteq_session_encoding='latin-1', bteq_output_width=12345, bteq_quit_zero=True, sp=None))
def test_build_bteq_file(self): # Given hook = TtuHook(ttu_conn_id='ttu_default') conn = hook.get_conn() # When bteq = hook._prepare_bteq_script(self._simple_bteq, conn['host'], conn['login'], conn['password'], conn['bteq_output_width'], conn['bteq_session_encoding'], conn['bteq_quit_zero'] ) # Then expected_bteq = """ .LOGON localhost/login, .SET WIDTH 65531; .SET SESSION CHARSET 'ASCII'; SELECT CURRENT_DATE; .IF ERRORCODE <> 0 THEN .QUIT 0300; .QUIT 0; """ self.assertEqual(expected_bteq, expected_bteq)
def test_prepare_bteq_script(self): # Given hook = TtuHook(ttu_conn_id='ttu_default') # When bteq_file = hook._prepare_bteq_script( self._simple_bteq, hook.get_conn()['host'], hook.get_conn()['login'], hook.get_conn()['password'], hook.get_conn()['bteq_output_width'], hook.get_conn()['bteq_session_encoding'], hook.get_conn()['bteq_quit_zero']) # Then expected_bteq_file = (".LOGON localhost/login,password;\n" ".SET WIDTH 65531;\n" ".SET SESSION CHARSET 'ASCII';\n" "SELECT CURRENT_DATE;\n" ".IF ERRORCODE <> 0 THEN .QUIT 0300;\n" ".LOGOFF;\n" ".EXIT;") self.assertEqual(expected_bteq_file, bteq_file)