@@ -808,6 +808,47 @@ def test_connect_with_preexisting_token_sans_user_and_pass(self):
808808 socket .write ("\r \n " .encode ('utf-8' ))
809809 socket .close ()
810810
811+
812+ class TestPostWithBodyParam (unittest .TestCase ):
813+
814+ def test_post (self ):
815+ def handler (url , message , ** kwargs ):
816+ assert url == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar"
817+ assert message ["body" ]["testkey" ] == "testvalue"
818+ return splunklib .data .Record ({
819+ "status" : 200 ,
820+ "headers" : [],
821+ })
822+ ctx = binding .Context (handler = handler )
823+ ctx .post ("foo/bar" , owner = "testowner" , app = "testapp" , body = {"testkey" : "testvalue" })
824+
825+ def test_post_with_params_and_body (self ):
826+ def handler (url , message , ** kwargs ):
827+ assert url == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar?extrakey=extraval"
828+ assert message ["body" ]["testkey" ] == "testvalue"
829+ return splunklib .data .Record ({
830+ "status" : 200 ,
831+ "headers" : [],
832+ })
833+ ctx = binding .Context (handler = handler )
834+ ctx .post ("foo/bar" , extrakey = "extraval" , owner = "testowner" , app = "testapp" , body = {"testkey" : "testvalue" })
835+
836+ def test_post_with_params_and_no_body (self ):
837+ def handler (url , message , ** kwargs ):
838+ assert url == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar"
839+ assert message ["body" ] == "extrakey=extraval"
840+ return splunklib .data .Record ({
841+ "status" : 200 ,
842+ "headers" : [],
843+ })
844+ ctx = binding .Context (handler = handler )
845+ ctx .post ("foo/bar" , extrakey = "extraval" , owner = "testowner" , app = "testapp" )
846+
847+ def test_with_body_with_full_request (self ):
848+ class TestRequestHandler (BaseHTTPRequestHandler ):
849+ pass
850+
851+
811852if __name__ == "__main__" :
812853 try :
813854 import unittest2 as unittest
0 commit comments