Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
djkhl committed Aug 29, 2024
1 parent 8c3256b commit 0832968
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 0 additions & 1 deletion logprep/framework/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ def process_pipeline(self) -> PipelineResult:
self.logger.error(",".join((str(error) for error in result.errors)))
self._store_failed_event(result.errors, result.event_received, event)
return

if self._output:
if self._pipeline:
result_data = [res.data for res in result if res.data]
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/framework/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,32 @@ def test_pipeline_result_provides_event_received(self, _):
assert result.event_received == {"some": "event"}, "received event is as expected"
assert result.event == {"some": "event", "field": "foo"}, "processed event is as expected"

def test_process_event_can_be_bypassed_with_no_pipeline(self, _):
self.pipeline._setup()
input_config = {
"testinput": {
"type": "http_input",
"uvicorn_config": {
"host": "127.0.0.1",
"port": 9000,
"ssl_certfile": "tests/testdata/acceptance/http_input/cert.crt",
"ssl_keyfile": "tests/testdata/acceptance/http_input/cert.key",
},
"endpoints": {"/json": "json", "/jsonl": "jsonl", "/plaintext": "plaintext"},
}
}
self.pipeline._input = original_create(input_config)
self.pipeline._input.pipeline_index = 1
self.pipeline._input.messages = multiprocessing.Queue(-1)
self.pipeline._input.setup()
self.pipeline._input.messages.put({"message": "test message"})
self.pipeline._pipeline = None
with mock.patch("logprep.framework.pipeline.Pipeline.process_event") as mock_process_event:
mock_process_event.return_value = None
result = self.pipeline.process_pipeline()
mock_process_event.assert_not_called()
assert isinstance(result, type(None))


class TestPipelineWithActualInput:
def setup_method(self):
Expand Down

0 comments on commit 0832968

Please sign in to comment.