def _get_output_speech_for_address(address): """ Creates output speech for trash day at the provided address :param address: Current address :return: Output speech string """ response = get_trash_day_json(address) try: first_feature = response[0] # Trash day is returned as "<DAY OF THE WEEK> Trash". We just want the # day so we split immediately trash_day = first_feature[ATTRIBUTES_PATH][NAME_PATH].split()[0] except (IndexError, KeyError): return intent_constants.NO_RESULTS_RESPONSE return OUTPUT_SPEECH_TEMPLATE.format(trash_day)
def test_get_trash_day_json(self): mock_call = mock.MagicMock( return_value=test_constants.GET_TRASH_PICKUP_API_MOCK) result = utils.get_trash_day_json(self.test_address, mock_call) self.assertEqual(result, test_constants.GET_TRASH_PICKUP_API_MOCK)