Skip to content

Commit 07176e7

Browse files
committed
Refactor test_serialize_message_not_dataclass and test_serialize_message_not_message in test_business_host.py
1 parent 2872a6f commit 07176e7

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/tests/test_business_host.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,33 @@ def test_dispatch_serializer():
1818

1919
def test_serialize_message_not_dataclass():
2020
bh = _BusinessHost()
21-
msg = TestSimpleMessageNotDataclass(integer=1, string='test')
22-
result = bh._serialize_message(msg)
23-
result.jstr.Rewind()
24-
stream = result.jstr.Read()
25-
assert result.classname == 'registerFiles.message.TestSimpleMessageNotDataclass'
21+
msg = TestSimpleMessageNotDataclass()
22+
msg.integer = 1
23+
msg.string = 'test'
24+
25+
# Mock iris_handler
26+
bh.iris_handle = MagicMock()
27+
28+
# expect an error
29+
try:
30+
bh.send_request_sync(target='test', request=msg)
31+
except Exception as e:
32+
assert type(e) == TypeError
33+
34+
def test_serialize_message_not_message():
35+
bh = _BusinessHost()
36+
msg = TestSimpleMessageNotMessage()
37+
msg.integer = 1
38+
msg.string = 'test'
39+
40+
# Mock iris_handler
41+
bh.iris_handle = MagicMock()
2642

43+
# expect an error
44+
try:
45+
bh.send_request_sync(target='test', request=msg)
46+
except Exception as e:
47+
assert type(e) == TypeError
2748

2849
def test_serialize_message_decorator():
2950
bh = _BusinessHost()

0 commit comments

Comments
 (0)