Commit b842d482 authored by Robin Obůrka's avatar Robin Obůrka Committed by Robin Obůrka

tests: Add test for out-only boxes generators

parent d474ad65
import pytest
from .conftest import build_msg
from unittest.mock import Mock
from unittest.mock import patch
import sn
......@@ -44,3 +46,19 @@ def test_passed_logger(in_out_args, good_msg):
sn.sn_main("test",
process=process,
args=in_out_args)
def test_generator(out_only_args, good_msg):
def generate(envdata, userdata):
for i in range(5):
yield "sentinel/test", { "foo": "bar" }
with patch("zmq.Socket.send_multipart", return_value=None) as send_function:
sn.sn_main("test",
process=generate,
args=out_only_args)
assert send_function.called
assert send_function.call_count == 5
args, _ = send_function.call_args
assert args[0] == build_msg("sentinel/test", { "foo": "bar" })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment