Skip to content

Commit a471525

Browse files
committed
more tests
Signed-off-by: Sreekanth <prsreekanth920@gmail.com>
1 parent a0a2eb9 commit a471525

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import pytest
2+
3+
from pynumaflow._validate import _validate_message_fields
4+
5+
6+
class TestValidateMessageFields:
7+
def test_invalid_value_type_raises(self):
8+
with pytest.raises(TypeError, match="Message 'value' must be bytes, got str"):
9+
_validate_message_fields("not bytes", None, None)
10+
11+
def test_invalid_keys_type_raises(self):
12+
with pytest.raises(TypeError, match="Message 'keys' must be a list of strings"):
13+
_validate_message_fields(None, "not-a-list", None)
14+
15+
def test_invalid_keys_element_type_raises(self):
16+
with pytest.raises(TypeError, match="Message 'keys' must be a list of strings"):
17+
_validate_message_fields(None, [1, 2], None)
18+
19+
def test_invalid_tags_type_raises(self):
20+
with pytest.raises(TypeError, match="Message 'tags' must be a list of strings"):
21+
_validate_message_fields(None, None, "not-a-list")
22+
23+
def test_invalid_tags_element_type_raises(self):
24+
with pytest.raises(TypeError, match="Message 'tags' must be a list of strings"):
25+
_validate_message_fields(None, None, [1, 2])
26+
27+
def test_valid_inputs_no_error(self):
28+
_validate_message_fields(b"data", ["key1"], ["tag1"])
29+
30+
def test_all_none_no_error(self):
31+
_validate_message_fields(None, None, None)

0 commit comments

Comments
 (0)