@@ -36,13 +36,13 @@ def test_capabilities(self):
3636 capabilities = self .service .capabilities
3737 self .assertTrue (isinstance (capabilities , list ))
3838 self .assertTrue (all ([isinstance (c , str ) for c in capabilities ]))
39- self .assertTrue ('change_own_password' in capabilities ) # This should always be there...
39+ self .assertTrue ('change_own_password' in capabilities ) # This should always be there...
4040
4141 def test_info (self ):
4242 info = self .service .info
4343 keys = ["build" , "cpu_arch" , "guid" , "isFree" , "isTrial" , "licenseKeys" ,
44- "licenseSignature" , "licenseState" , "master_guid" , "mode" ,
45- "os_build" , "os_name" , "os_version" , "serverName" , "version" ]
44+ "licenseSignature" , "licenseState" , "master_guid" , "mode" ,
45+ "os_build" , "os_name" , "os_version" , "serverName" , "version" ]
4646 for key in keys :
4747 self .assertTrue (key in list (info .keys ()))
4848
@@ -74,25 +74,25 @@ def test_app_namespace(self):
7474
7575 def test_owner_wildcard (self ):
7676 kwargs = self .opts .kwargs .copy ()
77- kwargs .update ({ 'app' : "search" , 'owner' : "-" })
77+ kwargs .update ({'app' : "search" , 'owner' : "-" })
7878 service_ns = client .connect (** kwargs )
7979 service_ns .apps .list ()
8080
8181 def test_default_app (self ):
8282 kwargs = self .opts .kwargs .copy ()
83- kwargs .update ({ 'app' : None , 'owner' : "admin" })
83+ kwargs .update ({'app' : None , 'owner' : "admin" })
8484 service_ns = client .connect (** kwargs )
8585 service_ns .apps .list ()
8686
8787 def test_app_wildcard (self ):
8888 kwargs = self .opts .kwargs .copy ()
89- kwargs .update ({ 'app' : "-" , 'owner' : "admin" })
89+ kwargs .update ({'app' : "-" , 'owner' : "admin" })
9090 service_ns = client .connect (** kwargs )
9191 service_ns .apps .list ()
9292
9393 def test_user_namespace (self ):
9494 kwargs = self .opts .kwargs .copy ()
95- kwargs .update ({ 'app' : "search" , 'owner' : "admin" })
95+ kwargs .update ({'app' : "search" , 'owner' : "admin" })
9696 service_ns = client .connect (** kwargs )
9797 service_ns .apps .list ()
9898
@@ -114,7 +114,7 @@ def test_parse_fail(self):
114114 def test_restart (self ):
115115 service = client .connect (** self .opts .kwargs )
116116 self .service .restart (timeout = 300 )
117- service .login () # Make sure we are awake
117+ service .login () # Make sure we are awake
118118
119119 def test_read_outputs_with_type (self ):
120120 name = testlib .tmpname ()
@@ -138,7 +138,7 @@ def test_splunk_version(self):
138138 for p in v :
139139 self .assertTrue (isinstance (p , int ) and p >= 0 )
140140
141- for version in [(4 ,3 , 3 ), (5 ,), (5 ,0 , 1 )]:
141+ for version in [(4 , 3 , 3 ), (5 ,), (5 , 0 , 1 )]:
142142 with self .fake_splunk_version (version ):
143143 self .assertEqual (version , self .service .splunk_version )
144144
@@ -167,15 +167,20 @@ def _create_unauthenticated_service(self):
167167 'scheme' : self .opts .kwargs ['scheme' ]
168168 })
169169
170- #To check the HEC event endpoint using Endpoint instance
170+ # To check the HEC event endpoint using Endpoint instance
171171 def test_hec_event (self ):
172172 import json
173173 service_hec = client .connect (host = 'localhost' , scheme = 'https' , port = 8088 ,
174174 token = "11111111-1111-1111-1111-1111111111113" )
175175 event_collector_endpoint = client .Endpoint (service_hec , "/services/collector/event" )
176176 msg = {"index" : "main" , "event" : "Hello World" }
177177 response = event_collector_endpoint .post ("" , body = json .dumps (msg ))
178- self .assertEqual (response .status ,200 )
178+ self .assertEqual (response .status , 200 )
179+
180+ def test_optional_retry (self ):
181+ service = client .connect (retries = 5 , retryBackoff = 5 , ** self .opts .kwargs )
182+ service .restart (timeout = 20 ) # less timeout so the optional retry logic is executed
183+ self .assertEqual (service .get ("/services" ).status , 200 )
179184
180185
181186class TestCookieAuthentication (unittest .TestCase ):
@@ -287,6 +292,7 @@ def test_login_with_multiple_cookies(self):
287292 service2 .login ()
288293 self .assertEqual (service2 .apps .get ().status , 200 )
289294
295+
290296class TestSettings (testlib .SDKTestCase ):
291297 def test_read_settings (self ):
292298 settings = self .service .settings
@@ -316,6 +322,7 @@ def test_update_settings(self):
316322 self .assertEqual (updated , original )
317323 self .restartSplunk ()
318324
325+
319326class TestTrailing (unittest .TestCase ):
320327 template = '/servicesNS/boris/search/another/path/segment/that runs on'
321328
@@ -329,19 +336,21 @@ def test_no_args_is_identity(self):
329336 self .assertEqual (self .template , client ._trailing (self .template ))
330337
331338 def test_trailing_with_one_arg_works (self ):
332- self .assertEqual ('boris/search/another/path/segment/that runs on' , client ._trailing (self .template , 'ervicesNS/' ))
339+ self .assertEqual ('boris/search/another/path/segment/that runs on' ,
340+ client ._trailing (self .template , 'ervicesNS/' ))
333341
334342 def test_trailing_with_n_args_works (self ):
335343 self .assertEqual (
336344 'another/path/segment/that runs on' ,
337345 client ._trailing (self .template , 'servicesNS/' , '/' , '/' )
338346 )
339347
348+
340349class TestEntityNamespacing (testlib .SDKTestCase ):
341350 def test_proper_namespace_with_arguments (self ):
342351 entity = self .service .apps ['search' ]
343- self .assertEqual ((None ,None ,"global" ), entity ._proper_namespace (sharing = "global" ))
344- self .assertEqual ((None ,"search" ,"app" ), entity ._proper_namespace (sharing = "app" , app = "search" ))
352+ self .assertEqual ((None , None , "global" ), entity ._proper_namespace (sharing = "global" ))
353+ self .assertEqual ((None , "search" , "app" ), entity ._proper_namespace (sharing = "app" , app = "search" ))
345354 self .assertEqual (
346355 ("admin" , "search" , "user" ),
347356 entity ._proper_namespace (sharing = "user" , app = "search" , owner = "admin" )
@@ -360,6 +369,7 @@ def test_proper_namespace_with_service_namespace(self):
360369 self .service .namespace .sharing )
361370 self .assertEqual (namespace , entity ._proper_namespace ())
362371
372+
363373if __name__ == "__main__" :
364374 try :
365375 import unittest2 as unittest
0 commit comments