def test_get_district_statistics_response_with_valid_details_returns_statistics_dict(
        district_statistics_dto, district_statistics_response):

    # Arrange
    presenter = PresenterImplementation()
    expected_dict = district_statistics_response

    # Act
    response = presenter.get_district_statistics_on_given_date_response(
        district_statistics_on_date_dto=district_statistics_dto)

    # Assert
    assert response == expected_dict
def test_get_state_cumulative_statistics_response_with_valid_details_returns_cumulative_dict(
        state_stats_dto, state_cumulative_response):

    # Arrange
    presenter = PresenterImplementation()
    expected_dict = state_cumulative_response

    # Act
    response = presenter.get_state_cumulative_statistics_response(
        state_cumulative_statistics_dto=state_stats_dto)

    # Assert
    assert response == expected_dict
Beispiel #3
0
def test_get_daily_statistics_response_with_valid_details_returns_statistics_dict(
        get_daily_statistics_dtos, get_daily_statistics_response):

    # Arrange
    presenter = PresenterImplementation()
    expected_dict = get_daily_statistics_response

    # Act
    response = presenter.get_daily_statistics_response(
        daily_statistics_dtos=get_daily_statistics_dtos)

    # Assert
    assert response == expected_dict
def test_raise_exception_for_invalid_number_raises_exception():

    # Arrange
    presenter = PresenterImplementation()
    exception_message = INVALID_POSITIVE_NUMBER[0]
    exception_res_status = INVALID_POSITIVE_NUMBER[1]

    # Act
    with pytest.raises(BadRequest) as exception:
        presenter.raise_exception_for_invalid_positive_number()

    # Assert
    assert exception.value.message == exception_message
    assert exception.value.res_status == exception_res_status
def test_raise_exception_for_invalid_district_raises_exception():

    # Arrange
    presenter = PresenterImplementation()
    exception_message = INVALID_DISTRICT_ID[0]
    exception_res_status = INVALID_DISTRICT_ID[1]

    # Act
    with pytest.raises(BadRequest) as exception:
        presenter.raise_exception_for_invalid_district()

    # Assert
    assert exception.value.message == exception_message
    assert exception.value.res_status == exception_res_status
Beispiel #6
0
def test_raise_exception_for_invalid_admin_raises_exception():

    # Arrange
    presenter = PresenterImplementation()
    exception_message = INVALID_ACCESS[0]
    exception_res_status = INVALID_ACCESS[1]

    # Act
    with pytest.raises(Forbidden) as exception:
        presenter.raise_exception_for_invalid_user_admin()

    # Assert
    assert exception.value.message == exception_message
    assert exception.value.res_status == exception_res_status
def test_get_day_wise_cumulative_statistics_response_with_valid_details_returns_cumulative_dict(
        mandals_day_wise_cumulative_stats,
        day_wise_mandals_cumulative_response):

    # Arrange
    presenter = PresenterImplementation()
    expected_dict = day_wise_mandals_cumulative_response

    # Act
    response = presenter.get_day_wise_mandals_cumulative_statistics_response(
        day_wise_mandals_cumulative_dtos=mandals_day_wise_cumulative_stats)

    # Assert
    assert response == expected_dict
Beispiel #8
0
def api_wrapper(*args, **kwargs):

    user = kwargs['user']
    request_data = kwargs['request_data']

    mandal_storage = MandalStorageImplementation()
    presenter = PresenterImplementation()

    user_id = user.id
    for_date = request_data['for_date']
    total_confirmed = request_data['total_confirmed']
    total_recovered = request_data['total_recovered']
    total_deaths = request_data['total_deaths']
    mandal_id = kwargs['mandal_id']

    interactor = CreateOrUpdateMandalStatisticsInteractor(
        mandal_storage=mandal_storage,
        presenter=presenter
    )

    interactor.create_or_update_mandal_statistics(
        user_id=user_id,
        for_date=for_date,
        total_confirmed=total_confirmed,
        total_recovered=total_recovered,
        total_deaths=total_deaths,
        mandal_id=mandal_id
    )

    return HttpResponse(status=201)
Beispiel #9
0
def api_wrapper(*args, **kwargs):

    storage = StateStorageImplementation()
    presenter = PresenterImplementation()

    interactor = StateDayWiseStatisticsInteractor(storage=storage,
                                                  presenter=presenter)
    response = interactor.get_day_wise_state_statistics()

    json_data = json.dumps(response)

    return HttpResponse(json_data, status=200)
def api_wrapper(*args, **kwargs):

    user = kwargs['user']
    user_id = user.id
    mandal_storage = MandalStorageImplementation()
    presenter = PresenterImplementation()

    interactor = DailyStatisticsInteractor(storage=mandal_storage,
                                           presenter=presenter)

    response = interactor.get_daily_statistics(user_id=user_id)

    json_data = json.dumps(response)

    return HttpResponse(json_data, status=200)
Beispiel #11
0
def api_wrapper(*args, **kwargs):

    request_data = kwargs['request_data']
    storage = StateStorageImplementation()
    presenter = PresenterImplementation()

    interactor = StateCumulativeStatisticsInteractor(storage=storage,
                                                     presenter=presenter)

    response = interactor.get_state_cumulative_statistics(
        till_date=request_data['till_date'])

    json_data = json.dumps(response)

    return HttpResponse(json_data, status=200)
def api_wrapper(*args, **kwargs):

    storage = StateStorageImplementation()
    presenter = PresenterImplementation()

    interactor = GetDistrictWiseZoneDetailsInteractor(
        storage=storage,
        presenter=presenter
    )

    response = interactor.get_district_wise_zone_details()

    json_data = json.dumps(response)

    return HttpResponse(json_data, status=200)
Beispiel #13
0
def api_wrapper(*args, **kwargs):

    district_id = kwargs['district_id']
    storage = DistrictStorageImplementation()
    presenter = PresenterImplementation()

    interactor = DistrictDayWiseCumulativeStatisticsInteractor(
        storage=storage, presenter=presenter)

    response = interactor.get_day_wise_district_cumulative_statistics(
        district_id=district_id)

    json_data = json.dumps(response)

    return HttpResponse(json_data, status=200)
Beispiel #14
0
def api_wrapper(*args, **kwargs):

    district_id = kwargs['district_id']
    district_storage = DistrictStorageImplementation()
    mandal_storage = MandalStorageImplementation()
    presenter = PresenterImplementation()

    interactor = MandalsDayWiseCumulativeStatisticsInteractor(
        district_storage=district_storage,
        mandal_storage=mandal_storage,
        presenter=presenter)

    response = interactor\
        .get_day_wise_mandals_cumulative_statistics_of_the_given_district(
            district_id=district_id
        )

    json_data = json.dumps(response)

    return HttpResponse(json_data, status=200)
Beispiel #15
0
def api_wrapper(*args, **kwargs):

    district_id = kwargs['district_id']
    request_data = kwargs['request_data']
    for_date = request_data['for_date']
    district_storage = DistrictStorageImplementation()
    mandal_storage = MandalStorageImplementation()
    presenter = PresenterImplementation()

    interactor = DistrictStatisticsInteractor(
        district_storage=district_storage,
        mandal_storage=mandal_storage,
        presenter=presenter)

    response = \
        interactor.get_district_statistics_on_given_date(
            district_id=district_id,
            for_date=for_date
        )

    json_data = json.dumps(response)

    return HttpResponse(json_data, status=200)