Skip to content

Commit b4e6097

Browse files
committed
initial end-to-end tests for streaming, reporting, generating
1 parent 7645d29 commit b4e6097

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

splunklib/searchcommands/search_command.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,8 @@ def _execute(self, ifile, process):
851851

852852
@staticmethod
853853
def _as_binary_stream(ifile):
854-
if six.PY2:
854+
naught = ifile.read(0)
855+
if isinstance(naught, bytes):
855856
return ifile
856857

857858
try:

tests/searchcommands/chunked_data_stream.py

Whitespace-only changes.

tests/searchcommands/test_generator_command.py

Whitespace-only changes.

tests/searchcommands/test_reporting_command.py

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import io
2+
from splunklib.searchcommands import StreamingCommand, Configuration
3+
4+
5+
def test_simple_streaming_command():
6+
@Configuration()
7+
class TestStreamingCommand(StreamingCommand):
8+
count = 0
9+
10+
def stream(self, records):
11+
for record in records:
12+
record["idx"] = self.count
13+
self.count += 1
14+
yield record
15+
16+
cmd = TestStreamingCommand()
17+
ifile = io.BytesIO()
18+
ofile = io.BytesIO()
19+
cmd._process_protocol_v2([], ifile, ofile)

0 commit comments

Comments
 (0)