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']
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']
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']
def edit_venue(venueId): venue = load_or_404(Venue, venueId) check_valid_edition(request, venue) validate_coordinates(request.json.get('latitude', None), request.json.get('longitude', None)) ensure_current_user_has_rights(RightsType.editor, venue.managingOffererId) venue.populate_from_dict(request.json) save_venue(venue) return jsonify(as_dict(venue, includes=VENUE_INCLUDES)), 200
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']
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']
def create_venue(): validate_coordinates(request.json.get('latitude', None), request.json.get('longitude', None)) venue = Venue(from_dict=request.json) venue.departementCode = 'XX' # avoid triggerring check on this siret = request.json.get('siret') if not siret: venue.generate_validation_token() save_venue(venue) if not venue.isValidated: try: send_venue_validation_email(venue, send_raw_email) except MailServiceException as e: app.logger.error('Mail service failure', e) return jsonify(as_dict(venue, includes=VENUE_INCLUDES)), 201