Skip to content

Commit a0f3666

Browse files
author
Frederick Ross
committed
Test suite skips all tests requiring app collection if it's not installed.
1 parent bb3ff94 commit a0f3666

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

tests/test_index.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
from os import path
1818
import time
1919
import testlib
20+
try:
21+
import unittest
22+
except ImportError:
23+
import unittest2 as unittest
2024

2125
import splunklib.client as client
2226

@@ -107,6 +111,7 @@ def test_submit_via_attached_socket(self):
107111
sock.send('Hello world!\r\n')
108112
self.assertEventuallyTrue(lambda: self.totalEventCount() == eventCount+1, timeout=60)
109113

114+
@unittest.skipUnless(testlib.has_app_collection, "Test requires sdk-app-collection.")
110115
def test_upload(self):
111116
self.install_app_from_collection("file_to_upload")
112117

tests/test_input.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
import testlib
1919
import logging
20+
try:
21+
import unittest
22+
except ImportError:
23+
import unittest2 as unittest
2024

2125
import splunklib.client as client
2226

@@ -143,6 +147,7 @@ def test_inputs_list_on_one_kind_with_search(self):
143147
found = [x.name for x in self.service.inputs.list('monitor', search=search)]
144148
self.assertEqual(expected, found)
145149

150+
@unittest.skipUnless(testlib.has_app_collection, "Test requires sdk-app-collection.")
146151
def test_oneshot(self):
147152
self.install_app_from_collection('file_to_upload')
148153

@@ -200,6 +205,7 @@ def test_list(self):
200205
for input in input_list:
201206
self.assertTrue(input.name is not None)
202207

208+
@unittest.skipUnless(testlib.has_app_collection, "Test requires sdk-app-collection.")
203209
def test_lists_modular_inputs(self):
204210
if self.service.splunk_version[0] < 5:
205211
return # Modular inputs don't exist prior to 5.0

tests/test_job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def test_read_jobs(self):
114114
job.refresh()
115115
self.check_job(job)
116116

117+
@unittest.skipUnless(testlib.has_app_collection, "Test requires sdk-app-collection.")
117118
class TestJobWithDelayedDone(testlib.SDKTestCase):
118119
def setUp(self):
119120
super(TestJobWithDelayedDone, self).setUp()

tests/test_modular_input_kinds.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
# under the License.
1616

1717
import testlib
18+
try:
19+
import unittest
20+
except ImportError:
21+
import unittest2 as unittest
1822
import splunklib.client as client
1923

24+
@unittest.skipUnless(testlib.has_app_collection, "Test requires sdk-app-collection.")
2025
class ModularInputKindTestCase(testlib.SDKTestCase):
2126
def setUp(self):
2227
super(ModularInputKindTestCase, self).setUp()

tests/testlib.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class NoRestartRequiredError(Exception):
5151
class WaitTimedOutError(Exception):
5252
pass
5353

54+
has_app_collection = False
55+
5456
def to_bool(x):
5557
if x == '1':
5658
return True
@@ -172,6 +174,10 @@ def install_app_from_collection(self, name):
172174
raise IOError("App %s not found in app collection" % name)
173175
self.installedApps.append(name)
174176

177+
def app_collection_installed(self):
178+
collectionName = 'sdk-app-collection'
179+
return collectionName in self.service.apps
180+
175181
def pathInApp(self, appName, pathComponents):
176182
"""Return a path to *pathComponents* in *appName*.
177183
@@ -227,6 +233,9 @@ def setUpClass(cls):
227233
if service.restart_required:
228234
service.restart(timeout=120)
229235

236+
global has_app_collection
237+
has_app_collection = 'sdk-app-collection' in service.apps
238+
230239
def setUp(self):
231240
unittest.TestCase.setUp(self)
232241
self.service = client.connect(**self.opts.kwargs)

0 commit comments

Comments
 (0)