Example #1
0
def test_map_request_data(client, jwt, app):
    """
    Setup:
    Test:
    Validate:
    :param client:
    :param jwt:
    :param app:
    :return:
    """
    nr_svc = NameRequestService()
    # Set data to the service
    input_data = {}
    nr_svc.request_data = input_data

    # Build the NR structure
    nr_model = build_nr(State.DRAFT)
    nr_model.save_to_db()

    # Apply the state change
    updated_nr_model = nr_svc.apply_state_change(
        nr_model, State.DRAFT, NameRequest.handle_name_request_update)

    # Test the result
    assert updated_nr_model is not None
def test_initial_to_reserved(client, jwt, app):
    """
    Setup:
    - Initialize NameRequestService
    - Create a new Request model instance
    Test:
    - Call apply_state_change on the NameRequestService instance
    - Make sure to pass in the Request model instance to apply_state_change
    - Make sure to pass in the appropriate apply_state_change handler eg. handle_name_request_<create|update> to apply_state_change
    Validate:
    - That the state change is successful
    :param client:
    :param jwt:
    :param app:
    :return:
    """
    nr_svc = NameRequestService()
    # Set data to the service
    input_data = {}
    nr_svc.request_data = input_data

    # Build the NR structure
    nr_model = build_nr(State.DRAFT)
    nr_model.save_to_db()

    # Apply the state change
    updated_nr_model = nr_svc.apply_state_change(
        nr_model, State.RESERVED, NameRequest.handle_name_request_update)

    # Test the result
    assert updated_nr_model is not None