Skip to content

Commit

Permalink
Fix bug in NameDay
Browse files Browse the repository at this point in the history
The default return value was "nobody" instead of None, making marvin
react to every message.
  • Loading branch information
kh31d4r committed Sep 30, 2024
1 parent d750592 commit c2c50d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion marvin_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test_marvin_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c2c50d8

Please sign in to comment.