generated from cern-sis/errbot-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_reminders.py
76 lines (54 loc) · 2.29 KB
/
test_reminders.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
import sys
from datetime import date, datetime
from freezegun import freeze_time
from reminder import Reminder
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(parent_dir)
@freeze_time("2023-06-15")
def test_get_monday():
assert Reminder.get_monday(datetime.now()) == date(2023, 6, 12)
@freeze_time("2023-06-12")
def test_is_spring_planning():
assert not Reminder.is_sprint_planning(datetime.now())
@freeze_time("2023-06-12")
def test_next_planning():
test_date = datetime(2023, 6, 12, 15, 32)
expected_result = datetime(2023, 6, 19, 15, 00).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, 14, 32)
expected_result = datetime(2023, 6, 15, 15, 00).strftime(
"**%Y-%m-%d** at **%H:%M**"
)
assert Reminder.next_occurance("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** at **%H:%M**")
assert Reminder.next_occurance("Retrospective", test_date) == expected_result
@freeze_time("2023-06-12 15:32", tz_offset=2)
def test_next_daily():
test_date = datetime(2023, 6, 12, 15, 32)
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():
planning_content = datetime(2023, 6, 19, 15, 00)
daily_content = datetime(2023, 6, 13, 9, 30)
review_content = datetime(2023, 6, 15, 15, 00)
restrospective_content = datetime(2023, 6, 16, 9, 30).strftime(
"**%Y-%m-%d** at **%H:%M**"
)
expected_response = "\n".join(
[
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