File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -44,8 +44,11 @@ def test_loop_basic(self) -> None:
44
44
ssl_context = ssl .create_default_context (),
45
45
)
46
46
47
- with patch .object (mqtt_client , "_wait_for_msg" ) as wait_for_msg_mock , \
48
- patch .object (mqtt_client , "is_connected" ) as is_connected_mock :
47
+ with patch .object (
48
+ mqtt_client , "_wait_for_msg"
49
+ ) as wait_for_msg_mock , patch .object (
50
+ mqtt_client , "is_connected"
51
+ ) as is_connected_mock :
49
52
50
53
wait_for_msg_mock .side_effect = self .fake_wait_for_msg
51
54
is_connected_mock .side_effect = lambda : True
@@ -66,6 +69,22 @@ def test_loop_basic(self) -> None:
66
69
assert ret_code == expected_rc
67
70
expected_rc += 1
68
71
72
+ def test_loop_is_connected (self ):
73
+ """
74
+ loop() should throw MMQTTException if not connected
75
+ """
76
+ mqtt_client = MQTT .MQTT (
77
+ broker = "127.0.0.1" ,
78
+ port = 1883 ,
79
+ socket_pool = socket ,
80
+ ssl_context = ssl .create_default_context (),
81
+ )
82
+
83
+ with self .assertRaises (MQTT .MMQTTException ) as context :
84
+ mqtt_client .loop (timeout = 1 )
85
+
86
+ assert "not connected" in str (context .exception )
87
+
69
88
70
89
if __name__ == "__main__" :
71
90
main ()
You can’t perform that action at this time.
0 commit comments