diff --git a/marvin_actions.py b/marvin_actions.py index d4d528c..9226414 100644 --- a/marvin_actions.py +++ b/marvin_actions.py @@ -494,7 +494,7 @@ def marvinNameday(row): """ Check current nameday """ - msg = getString("nameday", "nobody") + msg = None if any(r in row for r in ["nameday", "namnsdag"]): try: now = datetime.datetime.now() @@ -505,6 +505,8 @@ def marvinNameday(row): names = nameday_data["dagar"][0]["namnsdag"] if names: msg = getString("nameday", "somebody").format(",".join(names)) + else: + msg = getString("nameday", "nobody") except Exception: msg = getString("nameday", "error") return msg diff --git a/test_marvin_actions.py b/test_marvin_actions.py index 54fc5d6..9a7bce2 100644 --- a/test_marvin_actions.py +++ b/test_marvin_actions.py @@ -225,6 +225,10 @@ def testTimeToBBQ(self): self.assertBBQResponse(date(2024, 9, 13), date(2024, 9, 20), "week") self.assertBBQResponse(date(2024, 9, 4), date(2024, 9, 20), "base") + def testNameDayReaction(self): + """Test that marvin only responds to nameday when asked""" + self.assertActionSilent(marvin_actions.marvinNameday, "anything") + def testNameDayRequest(self): """Test that marvin sends a proper request for nameday info""" with mock.patch("marvin_actions.requests") as r: