コード例 #1
0
def get_iis_message(user_id, message_id):
    """
    :param user_id: email owner
    :param message_id: id message
    :return: model message with basic fields + header and data
    """
    log_info("Get iis message with message_id = {0} and user_id = {1}".format(
        message_id, user_id))
    response, model = UserMessages().get_iis(user_id, message_id)
    status_code = HttpLib.get_response_status_code(response)
    assert (status_code == status_code_200), \
        "Error! Get iis message with user_id = {0}, message_id = {1}. \n Status code is {2}, " \
        "\n Response text is {3}".format(user_id, message_id, status_code,
                                         response.get_response_text(response))
    return model
コード例 #2
0
def get_iis_message_with_attach(user_id, message_id, client_id=client):
    """
    :param user_id: email owner
    :param message_id: id message
    :param  client_id: auth data
    :return: full model message
    """
    log_info(
        "Get iis message for attach  with message_id = {0} and user_id = {1}".
        format(message_id, user_id))
    response, model = UserMessages().get_iis_with_attach(user_id, message_id)
    status_code = HttpLib.get_response_status_code(response)
    assert (status_code == status_code_200), \
        "Error! Get iis message for attach with user_id = {0}, message_id = {1}, \nStatus code is {2}, " \
        "\nResponse text is: {3}".format(user_id, message_id, status_code,
                                         response.get_response_text(response))
    return model
コード例 #3
0
def full_modify_messages(user_id,
                         message_id,
                         add_labels_list=None,
                         remove_labels_list=None):
    log_info("Full modify messages labels")
    actual_response, actual_model = UserMessages().\
        modify_messages(user_id, message_id, add_labels_list=add_labels_list, remove_label_list=remove_labels_list)
    assert (actual_response.status_code == status_code_200
            ), "Error when modify message: status code is not '200 OK'."
    return actual_model
コード例 #4
0
def modify_messages(user_id, message_id, add_labels_list):
    log_info("Modify messages labels")
    actual_response, actual_model = UserMessages().modify_messages(
        user_id, message_id, add_labels_list)
    status_code = HttpLib.get_response_status_code(actual_response)
    assert (status_code == status_code_200), \
        "Modify message error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(actual_response))
    return actual_model
コード例 #5
0
def check_message_is_deleted(user_id, message_id):
    """
    Args:
        user_id (str): user id (email)
        message_id (str)
    """
    response = UserMessages().basic_get(user_id, message_id,
                                        client_id=client).response
    log_info(
        "Check that message {message} is deleted".format(message=message_id))
    status_code = HttpLib.get_response_status_code(response)
    assert status_code == status_code_404, \
        "Message {message} is not deleted. Status code is {status_code} instead {expected_status_code}" \
        .format(message=message_id, status_code=status_code, expected_status_code=status_code_404)
コード例 #6
0
def send_message_with_attach(user_id, body_message_model):
    """
    :param user_id: email owner
    :param body_message_model: model with fields to send message
    :return: model message
    """
    raw = string_to_base64(
        create_multipart_mime_from_dict(
            body_message_model.get_dict_model_with_initialize_value()))
    response, model = UserMessages().send_message(user_id, raw)
    status_code = HttpLib.get_response_status_code(response)
    assert (status_code == status_code_200), \
        "Send message with attach message error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(response))
    return model
コード例 #7
0
def untrash_message(user_id, message_id):
    """
    Untrash message
    :param user_id:
    :param message_id:
    :return:
    """
    log_info("Untrash message with id={message_id} from user={user_id}".format(
        message_id=message_id, user_id=user_id))
    response, message_model = UserMessages().untrash(user_id, message_id)
    status_code = HttpLib.get_response_status_code(response)
    assert (status_code == status_code_200), \
        "Untrash message error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(response))
    return message_model
コード例 #8
0
def trash_message(user_id, message_id):
    """
    Moves the specified message to the trash
    :param user_id:
    :param message_id:
    """
    log_info("Trash message with id={mes_id} from user {user_id}".format(
        mes_id=message_id, user_id=user_id))
    response = UserMessages().trash_message(user_id=user_id,
                                            message_id=message_id)
    log_info("Assert status code for 'trash_message'")
    status_code = HttpLib.get_response_status_code(response)
    assert (status_code == status_code_200), \
        "Trash message error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(response))
コード例 #9
0
def batch_modify(user_id, list_id, list_label_ids):
    """
    Modifies the labels on the specified messages
    :param user_id
        :type: string
    :param list_id
        :type: list
    :param list_label_ids
        :type: list
    """
    actual_response = UserMessages().batch_modify(
        user_id=user_id, list_id=list_id, list_label_ids=list_label_ids)
    status_code = HttpLib.get_response_status_code(actual_response)
    assert (status_code == status_code_204), \
        "Batch modify error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(actual_response))
コード例 #10
0
def delete_message(user_id, message_id):
    """
    Deletes the specified message.

    :param message_id: the ID of the message to delete
    :param user_id: the user's email address
    """
    log_info("Delete message with id={mes_id} from user {user_id}".format(
        mes_id=message_id, user_id=user_id))
    response = UserMessages().delete(user_id=user_id, message_id=message_id)
    log_info("Assert status code for 'delete_message'" +
             str(response.status_code) + HttpLib.get_response_text(response))
    status_code = HttpLib.get_response_status_code(response)
    assert (status_code == status_code_204), \
        "Delete message error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(response))
コード例 #11
0
def import_message_with_attachment(user_id, message_body):
    """
    Args:
        user_id (str): user id (email)
        message_body (obj): message with attachment
    Returns:
        response, UserMessageModel model
    """
    raw = string_to_base64(
        create_multipart_mime_from_dict(
            message_body.get_dict_model_with_initialize_value()))
    response, model = UserMessages().import_text_message(user_id, raw)
    status_code = HttpLib.get_response_status_code(response)
    assert (status_code == status_code_200), \
        "Import message with attach message error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(response))
    return model
コード例 #12
0
def batch_delete(user_id, messages_id_list):
    """
    Deletes many messages by message ID
    Args:
        user_id(str): user email
        messages_id_list(list): list with messages id, which will be deleted
    """
    log_info('Message list contains: ' + str(len(messages_id_list)) +
             ' messages')
    request_body = create_string_from_json({"ids": messages_id_list})
    log_info("Messages will be deleted :" + request_body)
    response = UserMessages().batch_delete(user_id, request_body)
    log_info("Delete messages by ID")
    log_info("Assert status code for 'Batch delete'")
    status_code = HttpLib.get_response_status_code(response)
    assert (status_code == status_code_204), \
        "Batch delete error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(response))
コード例 #13
0
def get_messages_list(user_id, client_id=client):
    """
    Returns messages models array for currnet user_id
    Args:
        user_id(str): user email
        client_id(dict): auth data

    Returns:
        actual_model: user messages objects model array
    """

    log_info("Get messages models array")
    actual_response, actual_model = UserMessages().list(user_id, client_id)
    log_info("Assert status code")
    status_code = HttpLib.get_response_status_code(actual_response)
    assert (status_code == status_code_200), \
        "Get message list error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(actual_response))
    return actual_model
コード例 #14
0
def insert_message(user_id, insert_model):
    """
    Send request to get settings by id

    :param user_id: user email
    :param insert_model: model with fields to insert
    :return: message_model
    """
    message = string_to_base64(
        create_mime_from_dict(
            insert_model.get_dict_model_with_initialize_value()))
    log_info("Insert model")
    response, message_model = UserMessages().insert_message(user_id, message)
    message_model.raw = message
    log_info("Assert status code")
    status_code = HttpLib.get_response_status_code(response)
    assert (status_code == status_code_200), \
        "Insert message error: status code is {status_code}, response text is: {text}".format(
            status_code=status_code,
            text=HttpLib.get_response_text(response))
    return message_model