def test_messages(self, test_uuids): user = User("test_user") connection = Connection("test_user", conn_id=test_uuids[1]) connection.queue = Queue() connection2 = Connection("test_user", conn_id=test_uuids[2]) connection2.queue = Queue() user.add_connection(connection) user.add_connection(connection2) user.add_message({ "type": "message", "no_history": False, "pm_users": [], "exclude_users": [], }) assert len(user.connections) == 2 assert len(user.connections[0].queue.get()) == 1 assert len(user.connections[1].queue.get()) == 1
def test_messages(self, test_uuids): user = User("test_user") connection = Connection("test_user", conn_id=test_uuids[1]) connection.queue = Queue() connection2 = Connection("test_user", conn_id=test_uuids[2]) connection2.queue = Queue() user.add_connection(connection) user.add_connection(connection2) user.add_message( { "type": "message", "no_history": False, "pm_users": [], "exclude_users": [], } ) assert len(user.connections) == 2 assert len(user.connections[0].queue.get()) == 1 assert len(user.connections[1].queue.get()) == 1
def test_heartbeat(self, test_uuids): connection = Connection("test", test_uuids[1]) connection.queue = Queue() connection.heartbeat() assert connection.queue.get() == []
def test_message(self, test_uuids): connection = Connection("test", test_uuids[1]) connection.queue = Queue() connection.add_message({"message": "test"}) assert connection.queue.get() == [{"message": "test"}]