Skip to content

Commit b0da92b

Browse files
author
Shakeel Mohamed
committed
Fixed issues with script unit test in modular inputs.
1 parent 98afc11 commit b0da92b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/modularinput/test_script.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15-
from modularinput_testlib import unittest, xml_compare
15+
from tests.modularinput.modularinput_testlib import unittest, xml_compare
1616
from splunklib.modularinput.argument import Argument
1717
from splunklib.modularinput.event import Event
1818
from splunklib.modularinput.event_writer import EventWriter
@@ -29,7 +29,10 @@
2929
except ImportError:
3030
import xml.etree.ElementTree as ET
3131

32+
TEST_SCRIPT_PATH = "__IGNORED_SCRIPT_PATH__" #TODO: replace empty first args...
33+
3234
class ScriptTest(unittest.TestCase):
35+
3336
def test_error_on_script_with_null_scheme(self):
3437
"""A script that returns a null scheme should generate no output on
3538
stdout and an error on stderr saying that it the scheme was null."""
@@ -51,7 +54,7 @@ def stream_events(self, inputs, ew):
5154

5255
in_stream = StringIO()
5356

54-
args = ["--scheme"]
57+
args = [TEST_SCRIPT_PATH, "--scheme"]
5558
return_value = script.run_script(args, ew, in_stream)
5659

5760
self.assertEqual("", out.getvalue())
@@ -93,7 +96,7 @@ def stream_events(self, inputs, ew):
9396
err = StringIO()
9497
ew = EventWriter(out, err)
9598

96-
args = ["--scheme"]
99+
args = [TEST_SCRIPT_PATH, "--scheme"]
97100
return_value = script.run_script(args, ew, err)
98101

99102
self.assertEqual("", err.getvalue())
@@ -126,7 +129,7 @@ def stream_events(self, inputs, ew):
126129
err = StringIO()
127130
ew = EventWriter(out, err)
128131

129-
args = ["--validate-arguments"]
132+
args = [TEST_SCRIPT_PATH, "--validate-arguments"]
130133

131134
return_value = script.run_script(args, ew, open("data/validation.xml"))
132135

@@ -155,7 +158,7 @@ def stream_events(self, inputs, ew):
155158
err = StringIO()
156159
ew = EventWriter(out, err)
157160

158-
args = ["--validate-arguments"]
161+
args = [TEST_SCRIPT_PATH, "--validate-arguments"]
159162

160163
return_value = script.run_script(args, ew, open("data/validation.xml"))
161164

@@ -197,7 +200,7 @@ def stream_events(self, inputs, ew):
197200
err = StringIO()
198201
ew = EventWriter(out, err)
199202

200-
return_value = script.run_script([], ew, input_configuration)
203+
return_value = script.run_script([TEST_SCRIPT_PATH], ew, input_configuration)
201204

202205
self.assertEqual(0, return_value)
203206
self.assertEqual("", err.getvalue())

0 commit comments

Comments
 (0)