|
| 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 sys |
| 18 | +import unittest |
| 19 | + |
| 20 | +def read_baseline(filename): |
| 21 | + fd = open(filename, "r") |
| 22 | + baseline = fd.read().replace("\n", "") |
| 23 | + fd.close() |
| 24 | + return baseline |
| 25 | + |
| 26 | +class TestCase(unittest.TestCase): |
| 27 | + def check_module(self, modulename): |
| 28 | + __import__(modulename) |
| 29 | + module = sys.modules[modulename] |
| 30 | + names = str(dir(module)) |
| 31 | + baseline = read_baseline(modulename + ".baseline") |
| 32 | + self.assertEqual(names, baseline) |
| 33 | + |
| 34 | + def test_splunklib(self): |
| 35 | + self.check_module("splunklib") |
| 36 | + |
| 37 | + def test_binding(self): |
| 38 | + self.check_module("splunklib.binding") |
| 39 | + |
| 40 | + def test_client(self): |
| 41 | + self.check_module("splunklib.client") |
| 42 | + |
| 43 | + def test_data(self): |
| 44 | + self.check_module("splunklib.data") |
| 45 | + |
| 46 | + def test_results(self): |
| 47 | + self.check_module("splunklib.results") |
| 48 | + |
| 49 | +if __name__ == "__main__": |
| 50 | + unittest.main() |
0 commit comments