def test_message_unpin(): '''Message will be unpinned on the chat''' reset_data() data = auth_register('*****@*****.**', 'cs1531', 'Kevin', 'Trang') token = data['token'] channel_id = channels_create(token, 'Channel One', True) message_id = message_send(token, channel_id['channel_id'], 'Hello World') message_pin(token, message_id['message_id']) assert message_unpin(token, message_id['message_id']) == {}
def test_message_invalid_pin(): '''Pinned message will not be pinned again''' reset_data() data = auth_register('*****@*****.**', 'cs1531', 'Kevin', 'Trang') token = data['token'] channel_id = channels_create(token, 'Channel One', True) message_id = message_send(token, channel_id['channel_id'], 'Hello World') message_pin(token, message_id['message_id']) with pytest.raises(InputError): message_pin(token, message_id['message_id'])
def pin(): '''Pin message''' data = request.get_json() return dumps(message_pin(data["token"], data["message_id"]))