Esempio n. 1
0
 def test_presence_message_w_users(self, test_uuids):
     server_state = get_state()
     user = User("test_user")
     user.state_from_dict({"key": "1", "key2": "2"})
     user.state_public_keys = ["key2"]
     server_state.users[user.username] = user
     connection = Connection("test_user", conn_id=test_uuids[1])
     user.add_connection(connection)
     user2 = User("test_user2")
     user2.state_from_dict({"key": "1", "key2": "2"})
     server_state.users[user2.username] = user2
     connection2 = Connection("test_user2", conn_id=test_uuids[2])
     user2.add_connection(connection2)
     config = {
         "notify_presence": True,
         "broadcast_presence_with_user_lists": True
     }
     channel = Channel("test", channel_config=config)
     channel.add_connection(connection)
     channel.add_connection(connection2)
     payload = channel.send_notify_presence_info("test_user", "join")
     assert len(payload["users"]) == 2
     sorted_users = sorted(payload["users"], key=lambda x: x["user"])
     assert sorted_users == [
         {
             "state": {
                 "key2": "2"
             },
             "user": "******"
         },
         {
             "state": {},
             "user": "******"
         },
     ]
Esempio n. 2
0
 def test_presence_message(self, test_uuids):
     user = User("test_user")
     connection = Connection("test_user", conn_id=test_uuids[1])
     user.add_connection(connection)
     channel = Channel("test")
     channel.add_connection(connection)
     payload = channel.send_notify_presence_info("test_user", "join")
     assert payload["user"] == "test_user"
     assert payload["message"]["action"] == "join"
     assert payload["type"] == "presence"
     assert payload["channel"] == "test"
     assert len(payload["users"]) == 0
Esempio n. 3
0
 def test_presence_message(self, test_uuids):
     user = User("test_user")
     connection = Connection("test_user", conn_id=test_uuids[1])
     user.add_connection(connection)
     channel = Channel("test")
     channel.add_connection(connection)
     payload = channel.send_notify_presence_info("test_user", "join")
     assert payload["user"] == "test_user"
     assert payload["message"]["action"] == "join"
     assert payload["type"] == "presence"
     assert payload["channel"] == "test"
     assert len(payload["users"]) == 0
Esempio n. 4
0
 def test_presence_message_w_users(self, test_uuids):
     server_state = get_state()
     user = User("test_user")
     user.state_from_dict({"key": "1", "key2": "2"})
     user.state_public_keys = ["key2"]
     server_state.users[user.username] = user
     connection = Connection("test_user", conn_id=test_uuids[1])
     user.add_connection(connection)
     user2 = User("test_user2")
     user2.state_from_dict({"key": "1", "key2": "2"})
     server_state.users[user2.username] = user2
     connection2 = Connection("test_user2", conn_id=test_uuids[2])
     user2.add_connection(connection2)
     config = {"notify_presence": True, "broadcast_presence_with_user_lists": True}
     channel = Channel("test", channel_config=config)
     channel.add_connection(connection)
     channel.add_connection(connection2)
     payload = channel.send_notify_presence_info("test_user", "join")
     assert len(payload["users"]) == 2
     sorted_users = sorted(payload["users"], key=lambda x: x["user"])
     assert sorted_users == [
         {"state": {"key2": "2"}, "user": "******"},
         {"state": {}, "user": "******"},
     ]