Skip to content

Commit 7ec288b

Browse files
committed
Merge branch 'feature/units' into develop
2 parents 198be54 + 4154dc0 commit 7ec288b

21 files changed

+1213
-991
lines changed

tests/runtests.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@
2727
"test_data.py",
2828
"test_binding.py",
2929
"test_collection.py",
30-
"test_client.py",
30+
"test_app.py",
31+
"test_conf.py",
3132
"test_event_type.py",
3233
"test_fired_alert.py",
34+
"test_index.py",
35+
"test_input.py",
36+
"test_job.py",
37+
"test_logger.py",
38+
"test_message.py",
39+
"test_role.py",
40+
"test_user.py",
3341
"test_saved_search.py",
42+
"test_service.py",
3443
"test_examples.py",
3544
]
3645

tests/test_app.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2011-2012 Splunk, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"): you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
import splunklib.client as client
18+
19+
import testlib
20+
21+
class TestCase(testlib.TestCase):
22+
def check_app(self, app):
23+
app.name
24+
app.path
25+
app.content
26+
app.metadata
27+
28+
def test_read(self):
29+
service = client.connect(**self.opts.kwargs)
30+
31+
for app in service.apps:
32+
self.check_app(app)
33+
app.refresh()
34+
self.check_app(app)
35+
36+
def test_crud(self):
37+
service = client.connect(**self.opts.kwargs)
38+
39+
appname = "sdk-test-app"
40+
41+
testlib.delete_app(service, appname)
42+
self.assertFalse(appname in service.apps)
43+
44+
kwargs = {
45+
'author': "Me",
46+
'description': "Test app description",
47+
'label': "SDK Test",
48+
'manageable': False,
49+
'template': "barebones",
50+
'visible': True,
51+
}
52+
service.apps.create(appname, **kwargs)
53+
self.assertTrue(appname in service.apps)
54+
app = service.apps[appname]
55+
self.assertEqual(app['author'], "Me")
56+
self.assertEqual(app['label'], "SDK Test")
57+
self.assertEqual(app['manageable'], "0")
58+
self.assertEqual(app['visible'], "1")
59+
60+
kwargs = {
61+
'author': "SDK",
62+
'visible': False,
63+
}
64+
app = service.apps[appname]
65+
app.update(**kwargs)
66+
app.refresh()
67+
self.assertEqual(app['author'], "SDK")
68+
self.assertEqual(app['label'], "SDK Test")
69+
self.assertEqual(app['manageable'], "0")
70+
self.assertEqual(app['visible'], "0")
71+
72+
testlib.delete_app(service, appname)
73+
self.assertFalse(appname in service.apps)
74+
75+
if __name__ == "__main__":
76+
testlib.main()

0 commit comments

Comments
 (0)