Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-action: error correction #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions reminder.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def next_occurance(meeting, today):
next_occurance += delta_occurance

if next_occurance > today:
return next_occurance.strftime("%Y-%m-%d %H:%M")
return next_occurance.strftime("**%Y-%m-%d** at **%H:%M**")

@staticmethod
def next_daily(today):
Expand All @@ -82,17 +82,20 @@ def next_daily(today):
if next_daily.weekday() >= 3:
next_daily += timedelta(days=(7 - next_daily.weekday() + 1))

return next_daily.strftime("%Y-%m-%d %H:%M")
return next_daily.strftime("**%Y-%m-%d** at **%H:%M**")

@botcmd
def reminder_next(self, msg, args):
today = datetime.now()
next_planning = Reminder.next_occurance("Sprint planning", today)
next_daily = Reminder.next_daily(today)
next_review = Reminder.next_occurance("Sprint review", today)
next_retrospective = Reminder.next_occurance("Sprint retrospective", today)
return "\n".join(
[
f"Next planning:{Reminder.next_occurance('Sprint planning', today)}",
f"Next daily: {Reminder.next_daily(today)}",
f"Next review: {Reminder.next_occurance('Sprint review', today)}",
f"Next planning: {next_planning}",
f"Next daily: {next_daily}",
f"Next review: {next_review}",
f"Next retrospective: {next_retrospective}",
]
)
Expand Down
27 changes: 18 additions & 9 deletions tests/test_reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,27 @@ def test_is_spring_planning():
@freeze_time("2023-06-12")
def test_next_planning():
test_date = datetime(2023, 6, 12, 15, 32)
expected_result = datetime(2023, 6, 19, 15, 30).strftime("%Y-%m-%d %H:%M")
expected_result = datetime(2023, 6, 19, 15, 30).strftime(
"**%Y-%m-%d** at **%H:%M**"
)

assert Reminder.next_occurance("Sprint planning", test_date) == expected_result


@freeze_time("2023-06-12")
def test_next_review():
test_date = datetime(2023, 6, 12, 15, 32)
expected_result = datetime(2023, 6, 15, 14, 45).strftime("%Y-%m-%d %H:%M")
expected_result = datetime(2023, 6, 15, 14, 45).strftime(
"**%Y-%m-%d** at **%H:%M**"
)

assert Reminder.next_occurance("Sprint review", test_date) == expected_result


@freeze_time("2023-06-12")
def test_next_retrospective():
test_date = datetime(2023, 6, 12, 15, 32)
expected_result = datetime(2023, 6, 16, 9, 30).strftime("%Y-%m-%d %H:%M")
expected_result = datetime(2023, 6, 16, 9, 30).strftime("**%Y-%m-%d** at **%H:%M**")

assert Reminder.next_occurance("Sprint retrospective", test_date) == expected_result

Expand All @@ -49,20 +53,25 @@ def test_next_retrospective():
def test_next_daily():
test_date = datetime(2023, 6, 12, 15, 32)

expected_result = datetime(2023, 6, 13, 9, 30).strftime("%Y-%m-%d %H:%M")
expected_result = datetime(2023, 6, 13, 9, 30).strftime("**%Y-%m-%d** at **%H:%M**")

assert Reminder.next_daily(test_date) == expected_result


@freeze_time("2023-06-12")
def test_reminder_next():
restrospective_content = datetime(2023, 6, 16, 9, 30)
planning_content = datetime(2023, 6, 19, 15, 30)
daily_content = datetime(2023, 6, 13, 9, 30)
review_content = datetime(2023, 6, 15, 14, 45)
restrospective_content = datetime(2023, 6, 16, 9, 30).strftime(
"**%Y-%m-%d** at **%H:%M**"
)
expected_response = "\n".join(
[
f"Next planning:{datetime(2023, 6, 19, 15, 30).strftime('%Y-%m-%d %H:%M')}",
f"Next daily: {datetime(2023, 6, 13, 9, 30).strftime('%Y-%m-%d %H:%M')}",
f"Next review: {datetime(2023, 6, 15, 14, 45).strftime('%Y-%m-%d %H:%M')}",
f"Next retrospective: {restrospective_content.strftime('%Y-%m-%d %H:%M')}",
f"Next planning: {planning_content.strftime('**%Y-%m-%d** at **%H:%M**')}",
f"Next daily: {daily_content.strftime('**%Y-%m-%d** at **%H:%M**')}",
f"Next review: {review_content.strftime('**%Y-%m-%d** at **%H:%M**')}",
f"Next retrospective: {restrospective_content}",
]
)
assert Reminder.reminder_next(None, None, None) == expected_response