Skip to content

Commit f9ad478

Browse files
Test for allow_empty_input in generating commands
1 parent e8239e5 commit f9ad478

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/searchcommands/test_generator_command.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from . import chunked_data_stream as chunky
55

66
from splunklib.searchcommands import Configuration, GeneratingCommand
7+
from unittest import TestCase
78

89

910
def test_simple_generator():
@@ -41,4 +42,21 @@ def generate(self):
4142
assert finished_seen
4243

4344

45+
def test_allow_empty_input_for_generating_command():
46+
"""
47+
Passing allow_empty_input for generating command will cause an error
48+
"""
49+
@Configuration()
50+
class GeneratorTest(GeneratingCommand):
51+
def generate(self):
52+
for num in range(1, 3):
53+
yield {"_index": num}
54+
generator = GeneratorTest()
55+
in_stream = io.BytesIO()
56+
out_stream = io.BytesIO()
57+
58+
try:
59+
generator.process([], in_stream, out_stream, allow_empty_input=False)
60+
except ValueError as error:
61+
assert str(error) == "allow_empty_input cannot be False for Generating Commands"
4462

0 commit comments

Comments
 (0)