def search(request): place_name = request.GET["place_name"] place_type = request.GET["place_type"] nearby_places = request.GET["nearby_places"] message = SearchValidation.validate_place_name(place_name) if message["warning_message"] == "": json = Requests.request_recife_metropolitan_area_places(place_name, place_type) PlaceHelper.extract_places(json) return render(request, "templates/search.html", {"places": PlaceHelper.places}) else: return render(request, "templates/search.html", message)
def test_should_return_warning_message_for_nonexistent_place(self): message = SearchValidation.validate_place_name("aaaaaaaaaaaaaaaaaaaaaa") assert message["warning_message"] == "Estabelecimento não encontrado."
def test_should_return_empty_warning_message_for_existent_place_name(self): message = SearchValidation.validate_place_name("carrefour") assert message["warning_message"] == ""
def test_should_return_warning_message_when_search_field_is_empty(self): message = SearchValidation.validate_place_name("") assert message["warning_message"] == "Por favor, digite o nome do lugar que você deseja buscar."