@@ -47,6 +47,38 @@ def assert_callback(conn, result, data):
47
47
48
48
assert callback_called
49
49
50
+ def test_notify_multiple_messages (self , sqlitecloud_connection ):
51
+ connection , _ = sqlitecloud_connection
52
+
53
+ called_times = 3
54
+ flag = threading .Event ()
55
+
56
+ def assert_callback (conn , result , data ):
57
+ nonlocal called_times
58
+ nonlocal flag
59
+
60
+ if isinstance (result , SQLiteCloudResultSet ):
61
+ assert data == ["somedataX" ]
62
+ called_times -= 1
63
+ if called_times == 0 :
64
+ flag .set ()
65
+
66
+ pubsub = SQLiteCloudPubSub ()
67
+ subject_type = SQLITECLOUD_PUBSUB_SUBJECT .CHANNEL
68
+ channel = "channel" + str (uuid .uuid4 ())
69
+
70
+ pubsub .create_channel (connection , channel )
71
+ pubsub .listen (connection , subject_type , channel , assert_callback , ["somedataX" ])
72
+
73
+ pubsub .notify_channel (connection , channel , "somedataX" )
74
+ pubsub .notify_channel (connection , channel , "somedataX" )
75
+ pubsub .notify_channel (connection , channel , "somedataX" )
76
+
77
+ # wait for callback to be called
78
+ flag .wait (30 )
79
+
80
+ assert called_times == 0
81
+
50
82
def test_unlisten_channel (self , sqlitecloud_connection ):
51
83
connection , _ = sqlitecloud_connection
52
84
0 commit comments