def test_inclement_weather_alert_returns_normal_when_other_notice_in_alert_banner(self):
     snow_emergency_alert = "Patriots win the super bowl!"
     self.get_alerts_stub_return_dictionary = {
         get_alerts_intent.Services.ALERT_HEADER.value: snow_emergency_alert
     }
     response = get_alerts_intent.get_inclement_weather_alert(self.request, self.stub_get_alerts)
     self.assertEqual(constants.NO_INCLEMENT_WEATHER_ALERTS, response.output_speech)
 def test_inclement_weather_alert_returns_alerts_when_snow_in_alert_banner(self):
     snow_emergency_alert = "It's a snow emergency!"
     self.get_alerts_stub_return_dictionary = {
         get_alerts_intent.Services.ALERT_HEADER.value: snow_emergency_alert
     }
     response = get_alerts_intent.get_inclement_weather_alert(self.request, self.stub_get_alerts)
     self.assertEqual(snow_emergency_alert, response.output_speech)
Example #3
0
def on_intent(mycity_request):
    """
    If the event type is "request" and the request type is "IntentRequest",
    this function is called to execute the logic associated with the
    provided intent and build a response. Checks for required
    session_attributes when applicable.
    
    :param mycity_request: MyCityRequestDataModel object with
        request_type IntentRequest
    :return: MyCityRequestDataModel object corresponding to the intent_name
    :raises: ValueError
    """

    logger.debug('MyCityRequestDataModel received:' +
                 mycity_request.get_logger_string())

    if "Address" in mycity_request.intent_variables \
            and "value" in mycity_request.intent_variables["Address"]:
        # Some of our intents have an associated address value.
        # Capture that into session data here
        set_address_in_session(mycity_request)

    if "Zipcode" in mycity_request.intent_variables \
        and "value" in mycity_request.intent_variables["Zipcode"]:
        set_zipcode_in_session(mycity_request)

    # session_attributes = session.get("attributes", {})
    if mycity_request.intent_name == "GetAddressIntent":
        return get_address_from_session(mycity_request)
    elif mycity_request.intent_name == "TrashDayIntent":
        return get_trash_day_info(mycity_request)
    elif mycity_request.intent_name == "SnowParkingIntent":
        return get_snow_emergency_parking_intent(mycity_request)
    elif mycity_request.intent_name == "CrimeIncidentsIntent":
        return get_crime_incidents_intent(mycity_request)
    elif mycity_request.intent_name == "FoodTruckIntent":
        return get_nearby_food_trucks(mycity_request)
    elif mycity_request.intent_name == "GetAlertsIntent":
        return get_alerts_intent(mycity_request)
    elif mycity_request.intent_name == "AMAZON.HelpIntent":
        return get_help_response(mycity_request)
    elif mycity_request.intent_name == "AMAZON.StopIntent" or \
            mycity_request.intent_name == "AMAZON.CancelIntent" or \
            mycity_request.intent_name == "AMAZON.NavigateHomeIntent":
        return handle_session_end_request(mycity_request)
    elif mycity_request.intent_name == "FeedbackIntent":
        return submit_feedback(mycity_request)
    elif mycity_request.intent_name == "AMAZON.FallbackIntent":
        return fallback_intent(mycity_request)
    elif mycity_request.intent_name == "LatestThreeOneOne":
        return get_311_requests(mycity_request)
    elif mycity_request.intent_name == "InclementWeatherIntent":
        return get_inclement_weather_alert(mycity_request)
    elif mycity_request.intent_name == "FarmersMarketIntent":
        return get_farmers_markets_today(mycity_request)
    elif mycity_request.intent_name == "CoronavirusUpdateIntent":
        return get_coronovirus_update(mycity_request)
    else:
        raise ValueError("Invalid intent")
Example #4
0
 def test_inclement_weather_alert_returns_normal_response_for_keyword_in_wrong_alert_section(
         self):
     self.get_alerts_stub_return_dictionary = {
         get_alerts_intent.Services.PARKING_METERS:
         "Snow doesn't bother us!"
     }
     response = get_alerts_intent.get_inclement_weather_alert(
         self.request, self.stub_get_alerts)
     self.assertEqual(constants.NO_INCLEMENT_WEATHER_ALERTS,
                      response.output_speech)
 def test_inclement_weather_alert_returns_normal_response_for_no_alert(self):
     response = get_alerts_intent.get_inclement_weather_alert(self.request, self.stub_get_alerts)
     self.assertEqual(constants.NO_INCLEMENT_WEATHER_ALERTS, response.output_speech)