Ejemplo n.º 1
0
def test_post_ride_request_response():
    presenter = PresenterImplementation()
    expected_output = 201
    #Act
    actual_output = presenter.post_ride_request_response()
    #Assert
    assert actual_output.status_code == expected_output
Ejemplo n.º 2
0
def test_share_travel_info_response():
    #Arrange
    presenter = PresenterImplementation()
    expected_output = 201
    #Act
    actual_output = presenter.share_travel_info_response()
    # Assert
    assert actual_output.status_code == expected_output
Ejemplo n.º 3
0
def test_invalid_no_of_seats_returns_error_message(invalid_seats_fixture):
    #Arrange
    presenter = PresenterImplementation()
    expected_output = invalid_seats_fixture
    #Act
    actual_output = presenter.invalid_no_of_seats_returns_error_message()
    response = json.loads(actual_output.content)
    #Assert
    assert response == expected_output
Ejemplo n.º 4
0
def test_invalid_asset_quantity_given_returns_error_message(invalid_asset_type_fixture):
    #Arrange
    presenter = PresenterImplementation()
    expected_output = invalid_asset_type_fixture
    #Act
    actual_output = presenter.invalid_assets_quantity_given_returns_error_message()
    response = json.loads(actual_output.content)
    # Assert
    assert response == expected_output
Ejemplo n.º 5
0
def test_raise_exception_for_invalid_place_given(invalid_place_fixture):
    # Arrange
    presenter = PresenterImplementation()
    expected_output = invalid_place_fixture
    # Act
    actual_output = presenter.invalid_place_given_returns_error_response()
    response = json.loads(actual_output.content)
    # Assert
    assert response == expected_output
    def test_get_my_asset_request_when_no_requests_returns_empty_list(
            self, user_dtos, my_asset_request_dto_with_no_assert_requests,
            asset_request_response_with_no_asset_requests):

        #Arrange
        presenter = PresenterImplementation()
        expected_output = asset_request_response_with_no_asset_requests

        #Act
        result = presenter.get_my_asset_requests_response(
            my_asset_request_dto=my_asset_request_dto_with_no_assert_requests,
            user_dtos=user_dtos)

        #Assert
        assert result == expected_output
Ejemplo n.º 7
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    request_data = dict(kwargs['request_data'])
    user_id = user.id

    if request_data['is_flexible']:
        request_data['flexible_from_time'] += timedelta(hours=5, minutes=30)
        request_data['flexible_to_time'] += timedelta(hours=5, minutes=30)
    else:
        request_data['travel_date_time'] += timedelta(hours=5, minutes=30)

    assert_request_dto = AssetRequestDTO(
        from_place=request_data['from_place'],
        to_place=request_data['to_place'],
        travel_date_time=request_data['travel_date_time'],
        is_flexible=request_data['is_flexible'],
        flexible_from_time=request_data['flexible_from_time'],
        flexible_to_time=request_data['flexible_to_time'],
        no_of_assets=request_data['no_of_assets'],
        asset_type=request_data['asset_type'],
        asset_sensitivity=request_data['asset_sensitivity'],
        whom_to_deliver=request_data['whom_to_deliver'],
        user_id=user_id)

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = AssetRequestInteractor(storage=storage, presenter=presenter)
    return interactor.post_asset_request(asset_request_dto=assert_request_dto)
Ejemplo n.º 8
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    print("kwargs*******************",kwargs)
    query_params=kwargs["request_query_params"]
    print("query_params_status*******************",query_params.status)
    limit = query_params.limit
    offset = query_params.offset
    status = query_params.status
    order_by = 
    order = query_params.order

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = GetMyRideRequestsInteractor(storage=storage, presenter=presenter)

    request_dict=interactor.get_my_ride_requests(
        offset =offset,
        limit=limit,
        user_id = user_id,
        order=order,
        sort_by=sort_by,
        status = status
        )
    print(request_dict)
    response_data = json.dumps(request_dict)
    return HttpResponse(response_data, status=200)
Ejemplo n.º 9
0
    def test_user_login_returns_access_token_details(self, user_access_dto):

        #Arrange
        presenter = PresenterImplementation()
        expected_output = {
            'user_id': 3,
            'access_token': 'mbnZBmyNDz7KIRnTjQ3QBvnLAN7BTj',
            'refresh_token': 'qHCVVNwdm8OWw2nDH9XbsPyhI5lIQQ',
            'expires_in': '2052-02-10 20:56:09.642688'
        }
        #Act
        result = presenter.user_login_response(
            user_access_token_dto=user_access_dto)

        #Asset
        assert result == expected_output
Ejemplo n.º 10
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    request_data = kwargs['request_data']
    source = request_data["source"]
    destination = request_data["destination"]
    is_flexible = request_data["is_flexible"]
    from_datetime = request_data["from_datetime"]
    to_datetime = request_data["to_datetime"]
    datetime = request_data["datetime"]
    no_of_seats =request_data["no_of_seats"]
    luggage_quantity = request_data["luggage_quantity"]
    user_id = user.id

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = CreateRideRequestInteractor(storage=storage, presenter=presenter)

    interactor.create_ride_request(
        source=source,
        destination=destination ,
        is_flexible=is_flexible,
        datetime=datetime,
        from_datetime=from_datetime,
        to_datetime=to_datetime,
        no_of_seats=no_of_seats,
        luggage_quantity=luggage_quantity,
        user_id = user_id
        )
    return HttpResponse(status=201)
Ejemplo n.º 11
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    request_data = dict(kwargs['request_data'])
    user_id = user.id

    if request_data['is_flexible']:
        request_data['flexible_from_time'] += timedelta(hours=5, minutes=30)
        request_data['flexible_to_time'] += timedelta(hours=5, minutes=30)
    else:
        request_data['travel_date_time'] += timedelta(hours=5, minutes=30)

    share_travel_dto = ShareTravelInfoDTO(
        from_place=request_data['from_place'],
        to_place=request_data['to_place'],
        travel_date_time=request_data['travel_date_time'],
        is_flexible=request_data['is_flexible'],
        flexible_from_time=request_data['flexible_from_time'],
        flexible_to_time=request_data['flexible_to_time'],
        travel_medium=request_data['travel_medium'],
        assets_quantity=request_data['assets_quantity'],
        user_id=user_id
    )

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = ShareTravelInfoInteractor(
        storage=storage,
        presenter=presenter
    )

    response = interactor.post_share_travel_info(share_travel_dto=share_travel_dto)
    return response
Ejemplo n.º 12
0
def api_wrapper(*args, **kwargs):

    user = kwargs['user']
    request_data = dict(kwargs['request_data'])
    user_id = user.id
    if request_data['is_flexible']:
        request_data['flexible_from_time'] = request_data[
            'flexible_from_time'] + timedelta(hours=5, minutes=30)
        request_data['flexible_to_time'] = request_data[
            'flexible_to_time'] + timedelta(hours=5, minutes=30)
    else:
        request_data['travel_date_time'] = request_data[
            'travel_date_time'] + timedelta(hours=5, minutes=30)

    ride_request_dto = RideRequestDTO(
        from_place=request_data['from_place'],
        to_place=request_data['to_place'],
        is_flexible=request_data['is_flexible'],
        flexible_from_time=request_data['flexible_from_time'],
        flexible_to_time=request_data['flexible_to_time'],
        no_of_seats=request_data['no_of_seats'],
        luggage_quantity=request_data['luggage_quantity'],
        travel_date_time=request_data['travel_date_time'],
        user_id=user_id)

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = RideRequestInteractor(storage=storage, presenter=presenter)
    response = interactor.post_ride_details_from_user(
        ride_request_dto=ride_request_dto)
    return response
    def test_get_my_asset_request_response_returns_details_asset_requests(
            self, asset_request_dto1, my_asset_request_dto, create_users,
            create_asset_requests, asset_request_dto2, asset_request_response,
            user_dtos):

        #Arrange
        presenter = PresenterImplementation()
        expected_output = asset_request_response

        #Act
        print(my_asset_request_dto)
        result = presenter.get_my_asset_requests_response(
            my_asset_request_dto=my_asset_request_dto, user_dtos=user_dtos)

        #Assert
        assert result == expected_output
Ejemplo n.º 14
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    request_data = kwargs['request_data']
    source = request_data["source"]
    destination = request_data["destination"]
    is_flexible = request_data["is_flexible"]
    from_datetime = request_data["from_datetime"]
    to_datetime = request_data["to_datetime"]
    datetime = request_data["datetime"]
    medium = request_data["medium"]
    assets_quantity = request_data["assets_quantity"]
    user_id = user.id

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = CreateShareTravelInfoInteractor(storage=storage,
                                                 presenter=presenter)

    interactor.create_share_travel_info(source=source,
                                        destination=destination,
                                        is_flexible=is_flexible,
                                        datetime=datetime,
                                        from_datetime=from_datetime,
                                        to_datetime=to_datetime,
                                        medium=medium,
                                        assets_quantity=assets_quantity,
                                        user_id=user_id)
    return HttpResponse(status=201)
Ejemplo n.º 15
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    request_data = kwargs['request_data']
    source = request_data["source"]
    destination = request_data["destination"]
    is_flexible = request_data["is_flexible"]
    from_datetime = request_data["from_datetime"]
    to_datetime = request_data["to_datetime"]
    datetime = request_data["datetime"]
    no_of_assets =request_data["no_of_assets"]
    asset_type = request_data["asset_type"]
    sensitivity = request_data["sensitivity"]
    deliver_person  = request_data["deliver_person"]
    user_id = user.id

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = CreateAssetTransportRequestInteractor(
        storage=storage, presenter=presenter)

    interactor.create_asset_transport_request(
        source=source,
        destination=destination ,
        is_flexible=is_flexible,
        datetime=datetime,
        from_datetime=from_datetime,
        to_datetime=to_datetime,
        asset_type=asset_type,
        sensitivity=sensitivity,
        no_of_assets=no_of_assets,
        deliver_person=deliver_person,
        user_id = user_id
        )

    return HttpResponse(status=201)
    def test_get_my_asset_request_response_with_no_accepted_person_returns_empty_dict(
            self, asset_request_dto1_with_accepted_person_none,
            my_asset_request_dto_with_accepted_person_none, create_users,
            create_asset_requests, asset_request_dto2,
            asset_request_response_with_accepted_person_none, user_dtos):

        #Arrange
        presenter = PresenterImplementation()
        expected_output = asset_request_response_with_accepted_person_none

        #Act
        print(my_asset_request_dto_with_accepted_person_none)
        result = presenter.get_my_asset_requests_response(
            my_asset_request_dto=my_asset_request_dto_with_accepted_person_none,
            user_dtos=user_dtos)

        #Assert
        assert result == expected_output
    def test_get_my_ride_request_response_when_accepted_person_is_null(
            self, ride_request_dto1_with_accepted_person_none,
            my_ride_request_dto_with_accepted_person_none, create_users,
            create_ride_requests_with_accepted_person_none, ride_request_dto2,
            ride_request_response_with_accepted_person_none, user_dtos,
            ride_request_dtos):

        presenter = PresenterImplementation()
        expected_output = ride_request_response_with_accepted_person_none
        #print(ride_request_response)
        #Act
        print("*" * 180)
        print(my_ride_request_dto_with_accepted_person_none)
        result = presenter.get_my_ride_requests_response(
            my_ride_request_dto=my_ride_request_dto_with_accepted_person_none,
            user_dtos=user_dtos)

        #Assert
        assert result == expected_output
Ejemplo n.º 18
0
def api_wrapper(*args, **kwargs):
    request_data = kwargs['request_data']
    mobile_number = request_data.mobile_number
    user_name = request_data.user_name
    password = request_data.password

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = CreateUserInteractor(storage=storage, presenter=presenter)

    interactor.create_post(user_name=user_name,
                           password=password,
                           mobile_number=mobile_number)

    return HttpResponse(status=201)
Ejemplo n.º 19
0
def api_wrapper(*args, **kwargs):
    request_data = kwargs['request_data']
    mobile_number = request_data["mobile_number"]
    password = request_data["password"]

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    oauth_storage = OAuth2SQLStorage()
    interactor = UserLoginInteractor(storage=storage,
                                     presenter=presenter,
                                     oauth_storage=oauth_storage)

    access_token = interactor.user_login(password=password,
                                         mobile_number=mobile_number)

    response_data = json.dumps(access_token)
    return HttpResponse(response_data, status=200)
Ejemplo n.º 20
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    query_params=kwargs["request_query_params"]
    print("query_params_limit*******************",query_params.limit)
    print("query_params_offset*******************",query_params.offset)
    limit = query_params.limit
    offset = query_params.offset

    user_id = user.id

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = GetMatchingRideRequests(storage=storage, presenter=presenter)

    request_dict=interactor.get_matching_ride_requests(
        user_id = user_id,
        limit=limit,
        offset=offset)
    #print(request_dict)

    response_data = json.dumps(request_dict)
    return HttpResponse(response_data, status=200)
Ejemplo n.º 21
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    query_params = kwargs["request_query_params"]
    limit = query_params.limit
    offset = query_params.offset
    status = query_params.status
    sort_by = query_params.sort_by
    order_by = query_params.order_by
    user_id = user.id

    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = GetMyAssetRequestsInteractor(storage=storage,
                                              presenter=presenter)

    request_dict = interactor.get_my_asset_requests(offset=offset,
                                                    limit=limit,
                                                    order_by=order_by,
                                                    sort_by=sort_by,
                                                    status=status,
                                                    user_id=user_id)
    response_data = json.dumps(request_dict)
    return HttpResponse(response_data, status=200)