2121from splunklib import client
2222
2323
24-
2524def highest_port (service , base_port , * kinds ):
2625 """Find the first port >= base_port not in use by any input in kinds."""
2726 highest_port = base_port
@@ -45,7 +44,7 @@ def tearDown(self):
4544
4645 def create_tcp_input (self , base_port , kind , ** options ):
4746 port = base_port
48- while True : # Find the next unbound port
47+ while True : # Find the next unbound port
4948 try :
5049 input = self .service .inputs .create (str (port ), kind , ** options )
5150 return input
@@ -66,7 +65,7 @@ def test_cannot_create_with_restrictToHost_in_name(self):
6665 )
6766
6867 def test_create_tcp_ports_with_restrictToHost (self ):
69- for kind in ['tcp' , 'splunktcp' ]: # Multiplexed UDP ports are not supported
68+ for kind in ['tcp' , 'splunktcp' ]: # Multiplexed UDP ports are not supported
7069 # Make sure we can create two restricted inputs on the same port
7170 boris = self .service .inputs .create (str (self .base_port ), kind , restrictToHost = 'boris' )
7271 natasha = self .service .inputs .create (str (self .base_port ), kind , restrictToHost = 'natasha' )
@@ -101,7 +100,7 @@ def test_unrestricted_to_restricted_collision(self):
101100 unrestricted .delete ()
102101
103102 def test_update_restrictToHost_fails (self ):
104- for kind in ['tcp' , 'splunktcp' ]: # No UDP, since it's broken in Splunk
103+ for kind in ['tcp' , 'splunktcp' ]: # No UDP, since it's broken in Splunk
105104 boris = self .create_tcp_input (self .base_port , kind , restrictToHost = 'boris' )
106105
107106 self .assertRaises (
@@ -171,21 +170,22 @@ def test_oneshot(self):
171170
172171 def f ():
173172 index .refresh ()
174- return int (index ['totalEventCount' ]) == eventCount + 4
173+ return int (index ['totalEventCount' ]) == eventCount + 4
174+
175175 self .assertEventuallyTrue (f , timeout = 60 )
176176
177177 def test_oneshot_on_nonexistant_file (self ):
178178 name = testlib .tmpname ()
179179 self .assertRaises (HTTPError ,
180- self .service .inputs .oneshot , name )
180+ self .service .inputs .oneshot , name )
181181
182182
183183class TestInput (testlib .SDKTestCase ):
184184 def setUp (self ):
185185 super ().setUp ()
186186 inputs = self .service .inputs
187- unrestricted_port = str (highest_port (self .service , 10000 , 'tcp' , 'splunktcp' , 'udp' )+ 1 )
188- restricted_port = str (highest_port (self .service , int (unrestricted_port )+ 1 , 'tcp' , 'splunktcp' )+ 1 )
187+ unrestricted_port = str (highest_port (self .service , 10000 , 'tcp' , 'splunktcp' , 'udp' ) + 1 )
188+ restricted_port = str (highest_port (self .service , int (unrestricted_port ) + 1 , 'tcp' , 'splunktcp' ) + 1 )
189189 test_inputs = [{'kind' : 'tcp' , 'name' : unrestricted_port , 'host' : 'sdk-test' },
190190 {'kind' : 'udp' , 'name' : unrestricted_port , 'host' : 'sdk-test' },
191191 {'kind' : 'tcp' , 'name' : 'boris:' + restricted_port , 'host' : 'sdk-test' }]
@@ -223,7 +223,7 @@ def test_lists_modular_inputs(self):
223223 self .uncheckedRestartSplunk ()
224224
225225 inputs = self .service .inputs
226- if ('abcd' ,'test2' ) not in inputs :
226+ if ('abcd' , 'test2' ) not in inputs :
227227 inputs .create ('abcd' , 'test2' , field1 = 'boris' )
228228
229229 input = inputs ['abcd' , 'test2' ]
@@ -268,19 +268,19 @@ def test_update(self):
268268 @pytest .mark .skip ('flaky' )
269269 def test_delete (self ):
270270 inputs = self .service .inputs
271- remaining = len (self ._test_entities )- 1
271+ remaining = len (self ._test_entities ) - 1
272272 for input_entity in self ._test_entities .values ():
273273 name = input_entity .name
274274 kind = input_entity .kind
275275 self .assertTrue (name in inputs )
276- self .assertTrue ((name ,kind ) in inputs )
276+ self .assertTrue ((name , kind ) in inputs )
277277 if remaining == 0 :
278278 inputs .delete (name )
279279 self .assertFalse (name in inputs )
280280 else :
281281 if not name .startswith ('boris' ):
282282 self .assertRaises (client .AmbiguousReferenceException ,
283- inputs .delete , name )
283+ inputs .delete , name )
284284 self .service .inputs .delete (name , kind )
285285 self .assertFalse ((name , kind ) in inputs )
286286 self .assertRaises (client .HTTPError ,
@@ -290,4 +290,5 @@ def test_delete(self):
290290
291291if __name__ == "__main__" :
292292 import unittest
293+
293294 unittest .main ()
0 commit comments