Ejemplo n.º 1
0
def test_withdrawal(group_chat_channel2, user1, user2):
    with AuthenticatedClient(user1) as user1_sock:
        with AuthenticatedClient(user2) as user2_sock:
            user1_sock.sendobj(dict(method='withdrawal', channel=group_chat_channel2))
            response = user1_sock.recvobj()
            assert response['method'] == 'withdrawal'

            response = user2_sock.recvobj()
            assert response['method'] == 'publish'
            assert response['type'] == 'withdrawal'

    try:
        ChannelJoinInfo.get_item(group_chat_channel2, user1)
    except ItemNotFoundException:
        pass
    else:
        assert False
Ejemplo n.º 2
0
def test_withdrawal(group_chat_channel2, user1, user2):
    with AuthenticatedClient(user1) as user1_sock:
        with AuthenticatedClient(user2) as user2_sock:
            user1_sock.sendobj(
                dict(method='withdrawal', channel=group_chat_channel2))
            response = user1_sock.recvobj()
            assert response['method'] == 'withdrawal'

            response = user2_sock.recvobj()
            assert response['method'] == 'publish'
            assert response['type'] == 'withdrawal'

    try:
        ChannelJoinInfo.get_item(group_chat_channel2, user1)
    except ItemNotFoundException:
        pass
    else:
        assert False
Ejemplo n.º 3
0
 def make_client_attend_channel(self, message):
     data = bson.loads(message['data'])
     channel_users = set(data['users'])
     applying_users = set(self.factory.clients_by_user_id.keys()) & channel_users
     for user_id in applying_users:
         mine = ChannelJoinInfo.get_item(data['channel'], user_id)
         user_clients = self.factory.clients_by_user_id[user_id]
         for client in user_clients:
             client.user.join_infos_dict[data['channel']] = mine
             self.factory.clients_by_channel_name.setdefault(data['channel'], []).append(client)
Ejemplo n.º 4
0
def test_withdrawal(group_chat_channel2, user1, user2):
    with AuthenticatedClient(user1) as user1_sock:
        with AuthenticatedClient(user2) as user2_sock:
            user2_sock.sendobj(dict(method="attend", channel=group_chat_channel2))
            user2_sock.recvobj()

            user1_sock.sendobj(dict(method="withdrawal", channel=group_chat_channel2))
            response = user1_sock.recvobj()
            assert response["method"] == "withdrawal"

            response = user2_sock.recvobj()
            assert response["method"] == "publish"
            assert response["type"] == "withdrawal"

    try:
        ChannelJoinInfo.get_item(group_chat_channel2, user1)
    except ItemNotFoundException:
        pass
    else:
        assert False
Ejemplo n.º 5
0
 def make_client_attend_channel(self, message):
     data = bson.loads(message['data'])
     channel_users = set(data['users'])
     applying_users = set(
         self.factory.clients_by_user_id.keys()) & channel_users
     for user_id in applying_users:
         mine = ChannelJoinInfo.get_item(data['channel'], user_id)
         user_clients = self.factory.clients_by_user_id[user_id]
         for client in user_clients:
             client.user.join_infos_dict[data['channel']] = mine
             self.factory.clients_by_channel_name.setdefault(
                 data['channel'], []).append(client)