@@ -36,13 +36,13 @@ def test_capabilities(self):
36
36
capabilities = self .service .capabilities
37
37
self .assertTrue (isinstance (capabilities , list ))
38
38
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...
40
40
41
41
def test_info (self ):
42
42
info = self .service .info
43
43
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" ]
46
46
for key in keys :
47
47
self .assertTrue (key in list (info .keys ()))
48
48
@@ -74,25 +74,25 @@ def test_app_namespace(self):
74
74
75
75
def test_owner_wildcard (self ):
76
76
kwargs = self .opts .kwargs .copy ()
77
- kwargs .update ({ 'app' : "search" , 'owner' : "-" })
77
+ kwargs .update ({'app' : "search" , 'owner' : "-" })
78
78
service_ns = client .connect (** kwargs )
79
79
service_ns .apps .list ()
80
80
81
81
def test_default_app (self ):
82
82
kwargs = self .opts .kwargs .copy ()
83
- kwargs .update ({ 'app' : None , 'owner' : "admin" })
83
+ kwargs .update ({'app' : None , 'owner' : "admin" })
84
84
service_ns = client .connect (** kwargs )
85
85
service_ns .apps .list ()
86
86
87
87
def test_app_wildcard (self ):
88
88
kwargs = self .opts .kwargs .copy ()
89
- kwargs .update ({ 'app' : "-" , 'owner' : "admin" })
89
+ kwargs .update ({'app' : "-" , 'owner' : "admin" })
90
90
service_ns = client .connect (** kwargs )
91
91
service_ns .apps .list ()
92
92
93
93
def test_user_namespace (self ):
94
94
kwargs = self .opts .kwargs .copy ()
95
- kwargs .update ({ 'app' : "search" , 'owner' : "admin" })
95
+ kwargs .update ({'app' : "search" , 'owner' : "admin" })
96
96
service_ns = client .connect (** kwargs )
97
97
service_ns .apps .list ()
98
98
@@ -114,7 +114,7 @@ def test_parse_fail(self):
114
114
def test_restart (self ):
115
115
service = client .connect (** self .opts .kwargs )
116
116
self .service .restart (timeout = 300 )
117
- service .login () # Make sure we are awake
117
+ service .login () # Make sure we are awake
118
118
119
119
def test_read_outputs_with_type (self ):
120
120
name = testlib .tmpname ()
@@ -138,7 +138,7 @@ def test_splunk_version(self):
138
138
for p in v :
139
139
self .assertTrue (isinstance (p , int ) and p >= 0 )
140
140
141
- for version in [(4 ,3 , 3 ), (5 ,), (5 ,0 , 1 )]:
141
+ for version in [(4 , 3 , 3 ), (5 ,), (5 , 0 , 1 )]:
142
142
with self .fake_splunk_version (version ):
143
143
self .assertEqual (version , self .service .splunk_version )
144
144
@@ -167,15 +167,15 @@ def _create_unauthenticated_service(self):
167
167
'scheme' : self .opts .kwargs ['scheme' ]
168
168
})
169
169
170
- #To check the HEC event endpoint using Endpoint instance
170
+ # To check the HEC event endpoint using Endpoint instance
171
171
def test_hec_event (self ):
172
172
import json
173
173
service_hec = client .connect (host = 'localhost' , scheme = 'https' , port = 8088 ,
174
174
token = "11111111-1111-1111-1111-1111111111113" )
175
175
event_collector_endpoint = client .Endpoint (service_hec , "/services/collector/event" )
176
176
msg = {"index" : "main" , "event" : "Hello World" }
177
177
response = event_collector_endpoint .post ("" , body = json .dumps (msg ))
178
- self .assertEqual (response .status ,200 )
178
+ self .assertEqual (response .status , 200 )
179
179
180
180
181
181
class TestCookieAuthentication (unittest .TestCase ):
@@ -287,6 +287,7 @@ def test_login_with_multiple_cookies(self):
287
287
service2 .login ()
288
288
self .assertEqual (service2 .apps .get ().status , 200 )
289
289
290
+
290
291
class TestSettings (testlib .SDKTestCase ):
291
292
def test_read_settings (self ):
292
293
settings = self .service .settings
@@ -316,6 +317,7 @@ def test_update_settings(self):
316
317
self .assertEqual (updated , original )
317
318
self .restartSplunk ()
318
319
320
+
319
321
class TestTrailing (unittest .TestCase ):
320
322
template = '/servicesNS/boris/search/another/path/segment/that runs on'
321
323
@@ -329,19 +331,21 @@ def test_no_args_is_identity(self):
329
331
self .assertEqual (self .template , client ._trailing (self .template ))
330
332
331
333
def test_trailing_with_one_arg_works (self ):
332
- self .assertEqual ('boris/search/another/path/segment/that runs on' , client ._trailing (self .template , 'ervicesNS/' ))
334
+ self .assertEqual ('boris/search/another/path/segment/that runs on' ,
335
+ client ._trailing (self .template , 'ervicesNS/' ))
333
336
334
337
def test_trailing_with_n_args_works (self ):
335
338
self .assertEqual (
336
339
'another/path/segment/that runs on' ,
337
340
client ._trailing (self .template , 'servicesNS/' , '/' , '/' )
338
341
)
339
342
343
+
340
344
class TestEntityNamespacing (testlib .SDKTestCase ):
341
345
def test_proper_namespace_with_arguments (self ):
342
346
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" ))
347
+ self .assertEqual ((None , None , "global" ), entity ._proper_namespace (sharing = "global" ))
348
+ self .assertEqual ((None , "search" , "app" ), entity ._proper_namespace (sharing = "app" , app = "search" ))
345
349
self .assertEqual (
346
350
("admin" , "search" , "user" ),
347
351
entity ._proper_namespace (sharing = "user" , app = "search" , owner = "admin" )
@@ -360,6 +364,7 @@ def test_proper_namespace_with_service_namespace(self):
360
364
self .service .namespace .sharing )
361
365
self .assertEqual (namespace , entity ._proper_namespace ())
362
366
367
+
363
368
if __name__ == "__main__" :
364
369
try :
365
370
import unittest2 as unittest
0 commit comments