Пример #1
0
def test_post_ride_share_details():
    #Arrange
    ride_share_fctory = RideShareFactory()
    storage = StorageImplementation()
    #Act
    actual_output = storage.post_ride_share_details(
        ride_share_dto=ride_share_fctory)
    #Assert
    ride_id = RideShare.objects.get(id=actual_output).id
    assert actual_output == ride_id
Пример #2
0
def test_post_ride_share_details():
    # Arrange
    share_travel_dto = ShareTravelInfoFactory()
    storage = StorageImplementation()
    # Act
    actual_output = storage.post_share_travel_info(
        share_travel_dto=share_travel_dto)
    # Assert
    share_id = ShareTravelInfo.objects.get(id=actual_output).id
    assert actual_output == share_id
Пример #3
0
def test_post_ride_request_details():
    #Arrange
    ride_request_factory = RideRequestFactory()
    storage = StorageImplementation()
    #Act
    actual_output = storage.post_ride_request_details(
        ride_request_dto=ride_request_factory)
    #Assert
    ride_id = RideRequest.objects.get(id=actual_output).id
    assert ride_id == actual_output
Пример #4
0
def test_post_asset_request():
    #Arrange
    storage = StorageImplementation()
    asset_request_dto = AssetRequestDTOFactory
    print(asset_request_dto)
    #Act
    actual_output = storage.post_asset_request(
        asset_request_dto=asset_request_dto)
    #Assert
    is_valid = AssetRequest.objects.filter(id=actual_output).exists()
    assert True == is_valid
Пример #5
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
Пример #6
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)
Пример #7
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)
def test_get_asset_requests_when_no_requests_found():
    #Arrange
    user_id=1
    limit=10
    offset=1
    expected_output = []
    storage = StorageImplementation()
    
    #Act
    response = storage.get_my_asset_requests_dto(user_id=user_id,
                                                limit=limit,
                                                offset=offset)
                                                
    print("response:*****************",response)
    #Assert
    assert response == expected_output
Пример #9
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
Пример #10
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)
Пример #11
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)
Пример #12
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)
Пример #13
0
def test_create_asset_transport_request_creates_asset_transport_request_object_with_given_details(
        create_users):

    #Arrange
    source = "hyderabad"
    destination = "bangloor"
    is_flexible = True
    datetime = None
    from_datetime = "2020-09-04 06:00:00.000000-08:00"
    to_datetime = "2020-09-05 06:00:00.000000-08:00"
    no_of_assets = 2
    asset_type = AssetType.parcel.value
    sensitivity = SensitivityType.HighlySensitive.value
    deliver_person = "ram"
    user_id = 1
    storage = StorageImplementation()

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

    asset_transport_request = AssetTransportRequest.objects.get(
        source=source,
        destination=destination,
        is_flexible=is_flexible,
        datetime=datetime,
        from_datetime=from_datetime,
        to_datetime=to_datetime,
        user_id=user_id,
        no_of_assets=no_of_assets,
        asset_type=asset_type,
        sensitivity=sensitivity,
        deliver_person=deliver_person,
    )

    #Assert
    assert asset_transport_request.no_of_assets == no_of_assets
    assert asset_transport_request.sensitivity == sensitivity
def test_get_ride_requests_returns_ride_requets_list_requested_by_user(
        create_users, create_ride_requests, ride_request_dtos):
    #Arrange
    user_id = 1
    limit = 10
    offset = 1
    expected_output = ride_request_dtos
    print("ride_request_dtos:*****************", ride_request_dtos)
    storage = StorageImplementation()

    #Act
    response = storage.get_my_ride_requests_dto(user_id=user_id,
                                                limit=limit,
                                                offset=offset)

    print("response:*****************", response)
    #Assert
    assert response == expected_output
def test_get_asset_requests_returns_asset_trasnsport_requets_list_requested_by_user(
    create_users,create_asset_requests,asset_request_dtos
    ):
    #Arrange
    user_id=1
    limit=3
    offset=0
    expected_output = asset_request_dtos
    storage = StorageImplementation()
    
    #Act
    response = storage.get_my_asset_requests_dto(user_id=user_id,
                                                limit=limit,
                                                offset=offset)

    #Assert
    print("response:",response)
    assert response == expected_output
Пример #16
0
def test_create_share_travel_info_creates_share_travel_info_object_with_given_details(
        create_users):

    #Arrange
    source = "hyderabad"
    destination = "bangloor"
    is_flexible = True
    datetime = None
    from_datetime = "2020-09-04 06:00:00.000000-08:00"
    to_datetime = "2020-09-05 06:00:00.000000-08:00"
    assets_quantity = 2
    medium = MediumType.Bus.value
    user_id = 1
    storage = StorageImplementation()

    #Act
    storage.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)

    share_travel_info = ShareTravelInfo.objects.get(
        source=source,
        destination=destination,
        is_flexible=is_flexible,
        datetime=datetime,
        from_datetime=from_datetime,
        to_datetime=to_datetime,
        user_id=user_id,
        medium=medium,
        assets_quantity=assets_quantity,
    )

    #Assert
    assert share_travel_info.medium == medium
    assert share_travel_info.assets_quantity == assets_quantity
Пример #17
0
def test_create_share_ride_creates_share_ride__object_with_given_details(
        create_users):

    #Arrange
    source = "hyderabad"
    destination = "bangloor"
    is_flexible = True
    datetime = None
    from_datetime = "2020-09-04 06:00:00.000000-08:00"
    to_datetime = "2020-09-05 06:00:00.000000-08:00"
    no_of_seats_available = 2
    assets_quantity = 2
    user_id = 2
    storage = StorageImplementation()

    #Act
    storage.create_share_ride(source=source,
                              destination=destination,
                              is_flexible=is_flexible,
                              datetime=datetime,
                              from_datetime=from_datetime,
                              to_datetime=to_datetime,
                              no_of_seats_available=no_of_seats_available,
                              assets_quantity=assets_quantity,
                              user_id=user_id)

    share_ride = ShareRide.objects.get(
        source=source,
        destination=destination,
        is_flexible=is_flexible,
        datetime=datetime,
        from_datetime=from_datetime,
        to_datetime=to_datetime,
        user_id=user_id,
        no_of_seats_available=no_of_seats_available,
        assets_quantity=assets_quantity,
    )

    #Assert
    assert share_ride.no_of_seats_available == no_of_seats_available
    assert share_ride.assets_quantity == assets_quantity
def test_create_ride_request_creates_ride_request_object_with_given_details(
        create_users):

    #Arrange
    source = "hyderabad"
    destination = "bangloor"
    is_flexible = True
    datetime = None
    from_datetime = "2020-09-04 06:00:00.000000-08:00"
    to_datetime = "2020-09-05 06:00:00.000000-08:00"
    no_of_seats = 2
    luggage_quantity = 2
    user_id = 2
    storage = StorageImplementation()

    #Act
    storage.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)
    ride_request = RideRequest.objects.get(no_of_seats=no_of_seats,
                                           luggage_quantity=luggage_quantity,
                                           source=source,
                                           destination=destination,
                                           is_flexible=is_flexible,
                                           datetime=datetime,
                                           from_datetime=from_datetime,
                                           to_datetime=to_datetime,
                                           user_id=user_id)

    #Assert
    assert ride_request.no_of_seats == no_of_seats
    assert ride_request.luggage_quantity == luggage_quantity
Пример #19
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)
Пример #20
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)
Пример #21
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)
Пример #22
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)