Ejemplo n.º 1
0
def post_create_venue():
    validate_coordinates(request.json.get("latitude", None),
                         request.json.get("longitude", None))

    venue = create_venue(venue_properties=request.json, save=repository.save)

    return jsonify(as_dict(venue, includes=VENUE_INCLUDES)), 201
Ejemplo n.º 2
0
def test_validate_coordinates_raises_an_api_errors_if_latitude_is_not_a_decimal(
):
    # when
    with pytest.raises(ApiErrors) as e:
        validate_coordinates("48°4565", None)

    # then
    assert e.value.errors["latitude"] == ["Format incorrect"]
Ejemplo n.º 3
0
def test_validate_coordinates_raises_an_api_errors_for_both_latitude_and_longitude(
):
    # when
    with pytest.raises(ApiErrors) as e:
        validate_coordinates("53°4565", "48°4565")

    # then
    assert e.value.errors["latitude"] == ["Format incorrect"]
    assert e.value.errors["longitude"] == ["Format incorrect"]
Ejemplo n.º 4
0
def test_validate_coordinates_raises_an_api_errors_if_longitude_is_lower_than_minus_180(
):
    # when
    with pytest.raises(ApiErrors) as e:
        validate_coordinates(None, -182.66464)

    # then
    assert e.value.errors["longitude"] == [
        "La longitude doit être comprise entre -180.0 et +180.0"
    ]
Ejemplo n.º 5
0
def test_validate_coordinates_raises_an_api_errors_if_latitude_is_lower_than_minus_90(
):
    # when
    with pytest.raises(ApiErrors) as e:
        validate_coordinates(-92.543, None)

    # then
    assert e.value.errors["latitude"] == [
        "La latitude doit être comprise entre -90.0 et +90.0"
    ]
Ejemplo n.º 6
0
def test_validate_coordinates_raises_an_api_errors_if_both_latitude_and_longitude_are_out_of_bounds(
):
    # when
    with pytest.raises(ApiErrors) as e:
        validate_coordinates(93.46, -182.66464)

    # then
    assert e.value.errors["latitude"] == [
        "La latitude doit être comprise entre -90.0 et +90.0"
    ]
    assert e.value.errors["longitude"] == [
        "La longitude doit être comprise entre -180.0 et +180.0"
    ]
Ejemplo n.º 7
0
def edit_venue(venue_id):
    venue = load_or_404(Venue, venue_id)
    previous_venue = copy.deepcopy(venue)
    check_valid_edition(request, venue)
    validate_coordinates(request.json.get("latitude", None),
                         request.json.get("longitude", None))
    check_user_has_access_to_offerer(current_user, venue.managingOffererId)
    venue.populate_from_dict(request.json)

    if not venue.isVirtual:
        delete_venue_from_iris_venues(venue.id)

    repository.save(venue)
    link_valid_venue_to_irises(venue)

    if is_algolia_indexing(previous_venue, request.json):
        if feature_queries.is_active(FeatureToggle.SYNCHRONIZE_ALGOLIA):
            redis.add_venue_id(client=app.redis_client,
                               venue_id=dehumanize(venue_id))

    return jsonify(as_dict(venue, includes=VENUE_INCLUDES)), 200