def test_get_response_for_washing_machines_details():
    washing_machines_details_dtos_list= [WashingMachineDto(
                 washing_machine_id="wm1",
                 status="ACTIVE"),
            WashingMachineDto(
                 washing_machine_id="wm2",
                 status="INACTIVE"),
                 ]

    json_presenter = PresenterImplementation()
    expected_washing_machines_details_list = [
        {
            "washing_machine_id":"wm1",
            "status":"ACTIVE"
        },
        {
            "washing_machine_id":"wm2",
            "status":"INACTIVE"
        }
    ]

    actual_washing_machines_details_list = json_presenter.get_response_for_washing_machines_details(
        washing_machines_details_dtos_list=washing_machines_details_dtos_list
    )

    assert actual_washing_machines_details_list == expected_washing_machines_details_list
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    user_id = user.id
    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = GetPreviousSlotsInteractor(storage=storage,presenter=presenter)

    previous_slots_dict = interactor.get_previous_slots_interactor(user_id=user_id)
    response_data = json.dumps(previous_slots_dict)
    return HttpResponse(response_data, status=200)
def test_get_response_for_previous_slots():
    previous_slots_dto_list = [
        PreviousOrUpcommingSlotsDto(start_time="05:00",
                                    end_time="06:00",
                                    washing_machine_id=1,
                                    date="01-Jan-2020")
    ]

    json_presenter = PresenterImplementation()
    expected_previous_slots_list = [{
        "start_time": "05:00",
        "end_time": "06:00",
        "washing_machine_id": 1,
        "date": "01-Jan-2020"
    }]

    actual_previous_slots_list = json_presenter.get_reponse_for_previous_slots_list(
        previous_slots_list=previous_slots_dto_list)

    assert actual_previous_slots_list == expected_previous_slots_list
def api_wrapper(*args, **kwargs):
    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = GetWashingMachinesDetailsInteractor(storage=storage,
                                                     presenter=presenter)

    washing_machine_details_list = interactor.get_washing_machines_details_interactor(
    )

    response_data = json.dumps(washing_machine_details_list)
    return HttpResponse(response_data, status=200)
Exemplo n.º 5
0
def api_wrapper(*args, **kwargs):

    request_data = kwargs['request_data']
    washing_machine_id = request_data['washing_machine_id']
    status = request_data['status']
    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = AddAWashingMachineInteractor(storage=storage,
                                              presenter=presenter)

    interactor.add_a_washing_machine_interactor(
        washing_machine_id=washing_machine_id, status=status)

    return HttpResponse(status=201)
def api_wrapper(*args, **kwargs):
    request_data = kwargs['request_data']
    washing_machine_id = request_data['washing_machine_id']
    day = request_data['day']
    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = GetWashingMachineWiseDaySlotsInteractor(storage=storage,presenter=presenter)
    print("**********REquest****")
    washing_machine_wise_slots_dict = interactor.get_washing_machine_wise_day_wise_slots(
        washing_machine_id=washing_machine_id,
        day=day)
    print("**********END******")
    response_data = json.dumps(washing_machine_wise_slots_dict)
    return HttpResponse(response_data, status=200)
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    request_data = kwargs['request_data']
    username = request_data['username']
    password = request_data['password']
    storage = StorageImplementation()
    presenter = PresenterImplementation()
    oauth_storage = OAuth2SQLStorage()
    interactor = UserLginInteractor(storage=storage,
                                    presenter=presenter,
                                    oauth2_storage=oauth_storage)
    access_token = interactor.login(username=username, password=password)
    response_data = json.dumps(access_token)
    return HttpResponse(response_data, status=200)
Exemplo n.º 8
0
def api_wrapper(*args, **kwargs):

    user = kwargs['user']

    user_id = user.id

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

    slots_dict = interactor.get_slots_for_particular_days_with_avilablity_status(
        user_id=user_id)

    response_data = json.dumps(slots_dict)
    return HttpResponse(response_data, status=200)
Exemplo n.º 9
0
def api_wrapper(*args, **kwargs):
    user = kwargs['user']
    user_id = user.id
    request_data = kwargs['request_data']
    date = request_data['date']
    start_time = request_data['start_time']
    end_time = request_data['end_time']
    storage = StorageImplementation()
    presenter = PresenterImplementation()

    interactor = BookASlotInteractor(storage=storage, presenter=presenter)

    interactor.book_a_slot_interactor(user_id=user_id,
                                      date=date,
                                      start_time=start_time,
                                      end_time=end_time)

    return HttpResponse(status=201)
def test_get_response_for_washing_machine_wise_day_slots():
    washing_machine_wise_day_slots_dto_list= [WashingMachineWiseSlotDto(
                 start_time="05:00",
                 end_time="06:00")]

    json_presenter = PresenterImplementation()
    expected_washing_machine_wise_day_slots_list = [
        {
            "start_time":"05:00",
            "end_time":"06:00"
        }

    ]

    actual_washing_machine_wise_day_slots_list = json_presenter.\
    get_response_washing_machine_wise_day_wise_slots(
        slots_dto_list=washing_machine_wise_day_slots_dto_list
    )
    
    assert actual_washing_machine_wise_day_slots_list == expected_washing_machine_wise_day_slots_list
def api_wrapper(*args, **kwargs):
    print("1111111111")
    request_data = kwargs['request_data']
    washing_machine_id = request_data['washing_machine_id']
    day = request_data['day']
    start_time =request_data['start_time']
    end_time=request_data['end_time']
    storage = StorageImplementation()
    presenter = PresenterImplementation()
    print("222222222")
    interactor = AddWashingMachineWiseDaySlotsInteractor(storage=storage,presenter=presenter)

    interactor.add_washing_machine_wise_day_wise_slots(
        washing_machine_id=washing_machine_id,
        day=day,
        start_time=start_time,
        end_time=end_time)
    print("3333333")

    return HttpResponse(status=201)
def api_wrapper(*args, **kwargs):
    request_data = kwargs['request_data']
    washing_machine_id = request_data['washing_machine_id']
    day = request_data['day']
    limit = request_data['limit']
    offset = request_data['offset']
    
    washing_machine_wise_slots_input_dto = WashingMachineSlotInputDto(
        washing_machine_id = washing_machine_id,
        day = day,
        limit = limit,
        offset = offset
    )
    
    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = GetWashingMachineWiseDaySlotsInteractor(storage=storage,presenter=presenter)
    washing_machine_wise_slots_dict = interactor.get_washing_machine_wise_day_wise_slots(
        washing_machine_id=washing_machine_id,
        day=day)
    response_data = json.dumps(washing_machine_wise_slots_dict)
    return HttpResponse(response_data, status=200)
def api_wrapper(*args, **kwargs):
    request_data = kwargs['request_data']
    washing_machine_id = request_data['washing_machine_id']
    day = request_data['day']
    old_start_time = request_data['old_start_time']
    old_end_time = request_data['old_end_time']
    new_start_time = request_data['new_start_time']
    new_end_time = request_data['new_end_time']
    storage = StorageImplementation()
    presenter = PresenterImplementation()
    interactor = UpdateWashingMachineWiseDaySlotsInteractor(
        storage=storage, presenter=presenter)

    interactor.add_washing_machine_wise_day_wise_slots(
        washing_machine_id=washing_machine_id,
        day=day,
        old_start_time=old_start_time,
        old_end_time=old_end_time,
        new_start_time=new_start_time,
        new_end_time=new_end_time)

    return HttpResponse(status=201)