File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 2525import splunklib .client as client
2626import splunklib .results as results
2727
28- from splunklib .binding import _log_duration
28+ from splunklib .binding import _log_duration , HTTPError
29+
30+ from xml .etree .ElementTree import ParseError
2931
3032
3133class TestUtilities (testlib .SDKTestCase ):
@@ -343,6 +345,20 @@ def test_touch(self):
343345 self .fail ("Didn't wait long enough for TTL to change and make touch meaningful." )
344346 self .assertGreater (int (self .job ['ttl' ]), old_ttl )
345347
348+ def test_search_invalid_query_as_json (self ):
349+ args = {
350+ 'output_mode' : 'json' ,
351+ 'exec_mode' : 'normal'
352+ }
353+ try :
354+ self .service .jobs .create ('invalid query' , ** args )
355+ except ParseError as pe :
356+ self .fail ("Something went wrong with parsing the REST API response. %s" % pe .message )
357+ except HTTPError as he :
358+ self .assertEqual (he .status , 400 )
359+ except Exception as e :
360+ self .fail ("Got some unexpected error. %s" % e .message )
361+
346362
347363class TestResultsReader (unittest .TestCase ):
348364 def test_results_reader (self ):
You can’t perform that action at this time.
0 commit comments