@@ -40,10 +40,8 @@ def setUpModule():
4040
4141 print ("downloading aws provider for tests..." )
4242 res = PyStackQLTestsBase .stackql .executeStmt (registry_pull_aws_query )
43- print (res )
4443 print ("downloading google provider for tests..." )
4544 res = PyStackQLTestsBase .stackql .executeStmt (registry_pull_google_query )
46- print (res )
4745 print ("starting stackql server..." )
4846 PyStackQLTestsBase .server_process = subprocess .Popen ([PyStackQLTestsBase .stackql .bin_path , "srv" , "--pgsrv.address" , server_address , "--pgsrv.port" , str (server_port )])
4947 time .sleep (10 )
@@ -159,40 +157,37 @@ def test_10_executeStmt(self):
159157 okta_result = okta_result_dict ["message" ]
160158 expected_pattern = registry_pull_resp_pattern ("okta" )
161159 self .assertTrue (re .search (expected_pattern , okta_result ), f"Expected pattern not found in result: { okta_result } " )
162- github_result_dict = self .stackql .executeStmt (registry_pull_github_query )
163- github_result = github_result_dict ["message" ]
164- expected_pattern = registry_pull_resp_pattern ("github" )
165- self .assertTrue (re .search (expected_pattern , github_result ), f"Expected pattern not found in result: { github_result } " )
166- print_test_result (f"""Test 10 executeStmt method\n RESULTS:\n { okta_result_dict } \n { github_result_dict } """ , True )
160+ print_test_result (f"""Test 10 executeStmt method\n RESULTS:\n { okta_result_dict } """ , True )
167161
168162 @pystackql_test_setup (output = "csv" )
169163 def test_11_executeStmt_with_csv_output (self ):
170- okta_result = self .stackql .executeStmt (registry_pull_okta_query )
171- expected_pattern = registry_pull_resp_pattern ("okta" )
172- self .assertTrue (re .search (expected_pattern , okta_result ), f"Expected pattern not found in result: { okta_result } " )
173164 github_result = self .stackql .executeStmt (registry_pull_github_query )
174165 expected_pattern = registry_pull_resp_pattern ("github" )
175166 self .assertTrue (re .search (expected_pattern , github_result ), f"Expected pattern not found in result: { github_result } " )
176- print_test_result (f"""Test 11 executeStmt method with csv output\n RESULTS:\n { okta_result } \n { github_result } """ , True )
167+ print_test_result (f"""Test 11 executeStmt method with csv output\n RESULTS:\n { github_result } """ , True )
177168
178169 @pystackql_test_setup (output = "pandas" )
179170 def test_12_executeStmt_with_pandas_output (self ):
180- okta_result_df = self .stackql .executeStmt (registry_pull_okta_query )
181- okta_result = okta_result_df ['message' ].iloc [0 ]
182- expected_pattern = registry_pull_resp_pattern ("okta" )
183- self .assertTrue (re .search (expected_pattern , okta_result ), f"Expected pattern not found in result: { okta_result } " )
184- github_result_df = self .stackql .executeStmt (registry_pull_github_query )
185- github_result = github_result_df ['message' ].iloc [0 ]
186- expected_pattern = registry_pull_resp_pattern ("github" )
187- self .assertTrue (re .search (expected_pattern , github_result ), f"Expected pattern not found in result: { github_result } " )
188- print_test_result (f"""Test 12 executeStmt method with pandas output\n RESULTS:\n { okta_result_df } \n { github_result_df } """ , True )
171+ homebrew_result_df = self .stackql .executeStmt (registry_pull_homebrew_query )
172+ homebrew_result = homebrew_result_df ['message' ].iloc [0 ]
173+ expected_pattern = registry_pull_resp_pattern ("homebrew" )
174+ self .assertTrue (re .search (expected_pattern , homebrew_result ), f"Expected pattern not found in result: { homebrew_result } " )
175+ print_test_result (f"""Test 12 executeStmt method with pandas output\n RESULTS:\n { homebrew_result_df } """ , True )
189176
190177 @pystackql_test_setup ()
191178 def test_13_execute_with_defaults (self ):
192- result = self .stackql .execute (google_query )
193- is_valid_data_resp = isinstance (result , list ) and all (isinstance (item , dict ) for item in result )
194- self .assertTrue (is_valid_data_resp , f"Result is not valid: { result } " )
195- print_test_result (f"Test 13 execute with defaults\n RESULT: { result } " , is_valid_data_resp )
179+ result = self .stackql .execute (google_show_services_query )
180+ is_valid_data_resp = (
181+ isinstance (result , list )
182+ and all (isinstance (item , dict ) and 'error' not in item for item in result )
183+ )
184+ # Truncate the result message if it's too long
185+ truncated_result = (
186+ str (result )[:500 ] + '...' if len (str (result )) > 500 else str (result )
187+ )
188+ self .assertTrue (is_valid_data_resp , f"Result is not valid: { truncated_result } " )
189+ print_test_result (f"Test 13 execute with defaults\n RESULT: { truncated_result } " , is_valid_data_resp )
190+
196191
197192 def test_14_execute_with_defaults_null_response (self ):
198193 result = self .stackql .execute ("SELECT 1 WHERE 1=0" )
@@ -234,29 +229,23 @@ def test_16_execute_with_csv_output(self, mock_execute):
234229
235230 @pystackql_test_setup ()
236231 def test_17_execute_default_auth_dict_output (self ):
237- query = "select login from github.users.users"
238- result = self .stackql .execute (query )
239-
232+ result = self .stackql .execute (github_query )
240233 # Expected result based on default auth
241234 expected_result = [
242235 {"login" : "stackql-devops-1" }
243236 ]
244-
245237 self .assertTrue (isinstance (result , list ), "Result should be a list" )
246238 self .assertEqual (result , expected_result , f"Expected result: { expected_result } , got: { result } " )
247239 print_test_result (f"Test 17 execute with default auth and dict output\n RESULT: { result } " , result == expected_result )
248240
249241
250242 @pystackql_test_setup ()
251243 def test_18_execute_custom_auth_env_vars (self ):
252- query = "select login from github.users.users"
253-
254244 # Set up custom environment variables for authentication
255245 env_vars = {
256246 'command_specific_username' : os .getenv ('CUSTOM_STACKQL_GITHUB_USERNAME' ),
257247 'command_specific_password' : os .getenv ('CUSTOM_STACKQL_GITHUB_PASSWORD' )
258248 }
259-
260249 # Define custom authentication configuration
261250 custom_auth = {
262251 "github" : {
@@ -265,14 +254,11 @@ def test_18_execute_custom_auth_env_vars(self):
265254 "password_var" : "command_specific_password"
266255 }
267256 }
268-
269- result = self .stackql .execute (query , custom_auth = custom_auth , env_vars = env_vars )
270-
257+ result = self .stackql .execute (github_query , custom_auth = custom_auth , env_vars = env_vars )
271258 # Expected result based on custom auth
272259 expected_result = [
273260 {"login" : "stackql-devops-2" }
274261 ]
275-
276262 self .assertTrue (isinstance (result , list ), "Result should be a list" )
277263 self .assertEqual (result , expected_result , f"Expected result: { expected_result } , got: { result } " )
278264 print_test_result (f"Test 18 execute with custom auth and command-specific environment variables\n RESULT: { result } " , result == expected_result )
0 commit comments