Skip to content

Commit

Permalink
fix: don't throw an exception when successful (#6)
Browse files Browse the repository at this point in the history
* fix: don't throw an exception when successful
  • Loading branch information
mikejgray authored May 30, 2024
1 parent a80d1f8 commit 4be26e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def handle_add_meal(self, _: Message):
self.log.info(f"Adding a new meal: {new_meal}")
if new_meal:
self.meals = f"{self.meals},{new_meal}"
self.speak_dialog("meal.added")
self.speak_dialog("meal.added", {"new_meal": new_meal})
except Exception as err:
self.log.exception(err)
self.speak_dialog("failed.to.add.meal")
Expand Down
21 changes: 20 additions & 1 deletion test/test_skill.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=missing-docstring
# pylint: disable=missing-docstring,redefined-outer-name
import shutil
import string
from json import dumps
Expand Down Expand Up @@ -92,6 +92,25 @@ def test_long_list_of_meals(self, test_skill):
},
)

@pytest.mark.parametrize("meal", [
"cheeseburgers",
"spaghetti carbonara",
"sushi",
"dahl",
"lengua tacos",
"moussaka",
"feijoada",
"pad thai",
"tagine",
])
def test_add_meal(self, test_skill, meal):
test_skill.ask_yesno = Mock()
test_skill.get_response = Mock(return_value=meal)
test_skill.handle_add_meal(None)
test_skill.speak_dialog.assert_called()
test_skill.ask_yesno.assert_not_called()
test_skill.speak_dialog.assert_called_with("meal.added", {"new_meal": meal})


if __name__ == "__main__":
pytest.main()

0 comments on commit 4be26e8

Please sign in to comment.