From d42f26dad850e68e3749cd0946eb031d80ccf77c Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Fri, 13 Dec 2024 11:16:23 +0100 Subject: [PATCH] tests(redis_connector): fixed test for messages that are not BECMessages --- bec_lib/tests/test_redis_connector.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/bec_lib/tests/test_redis_connector.py b/bec_lib/tests/test_redis_connector.py index 0374da51..38b85e76 100644 --- a/bec_lib/tests/test_redis_connector.py +++ b/bec_lib/tests/test_redis_connector.py @@ -236,19 +236,16 @@ def test_redis_connector_lrange(connector, topic, start, end, use_pipe): ) def test_redis_connector_set_and_publish(connector, topic, msg, pipe, expire): if not isinstance(msg, BECMessage): - with pytest.raises(TypeError): - connector.set_and_publish(topic, msg, pipe, expire) + msg_sent = msg else: - connector.set_and_publish(topic, msg, pipe, expire) + msg_sent = MsgpackSerialization.dumps(msg) - connector._redis_conn.pipeline().publish.assert_called_once_with( - topic, MsgpackSerialization.dumps(msg) - ) - connector._redis_conn.pipeline().set.assert_called_once_with( - topic, MsgpackSerialization.dumps(msg), ex=expire - ) - if not pipe: - connector._redis_conn.pipeline().execute.assert_called_once() + connector.set_and_publish(topic, msg, pipe, expire) + + connector._redis_conn.pipeline().publish.assert_called_once_with(topic, msg_sent) + connector._redis_conn.pipeline().set.assert_called_once_with(topic, msg_sent, ex=expire) + if not pipe: + connector._redis_conn.pipeline().execute.assert_called_once() @pytest.mark.parametrize("topic, msg, expire", [["topic1", "msg1", None], ["topic2", "msg2", 400]])