@@ -95,42 +95,36 @@ def test_get_youre_going_oncall_notification_title(make_organization_and_user, m
95
95
##################
96
96
# same day shift
97
97
##################
98
- same_day_shift_title = tasks ._get_youre_going_oncall_notification_title (
99
- schedule , seconds_until_going_oncall , same_day_shift , maus
100
- )
101
- same_day_shift_no_locale_title = tasks ._get_youre_going_oncall_notification_title (
102
- schedule , seconds_until_going_oncall , same_day_shift , maus_no_locale
98
+ same_day_shift_title = tasks ._get_youre_going_oncall_notification_title (seconds_until_going_oncall )
99
+ same_day_shift_subtitle = tasks ._get_youre_going_oncall_notification_subtitle (schedule , same_day_shift , maus )
100
+ same_day_shift_no_locale_subtitle = tasks ._get_youre_going_oncall_notification_subtitle (
101
+ schedule , same_day_shift , maus_no_locale
103
102
)
104
103
105
- assert (
106
- same_day_shift_title
107
- == f"You're going on call in { humanized_time_until_going_oncall } for schedule { schedule_name } , 09 h 00 - 17 h 00"
108
- )
109
- assert (
110
- same_day_shift_no_locale_title
111
- == f"You're going on call in { humanized_time_until_going_oncall } for schedule { schedule_name } , 9:00\u202f AM - 5:00\u202f PM"
112
- )
104
+ assert same_day_shift_title == f"Your on-call shift starts in { humanized_time_until_going_oncall } "
105
+ assert same_day_shift_subtitle == f"09 h 00 - 17 h 00\n Schedule { schedule_name } "
106
+ assert same_day_shift_no_locale_subtitle == f"9:00\u202f AM - 5:00\u202f PM\n Schedule { schedule_name } "
113
107
114
108
##################
115
109
# multiple day shift
116
110
##################
117
- multiple_day_shift_title = tasks ._get_youre_going_oncall_notification_title (
118
- schedule , seconds_until_going_oncall , multiple_day_shift , maus
111
+ multiple_day_shift_title = tasks ._get_youre_going_oncall_notification_title (seconds_until_going_oncall )
112
+ multiple_day_shift_subtitle = tasks ._get_youre_going_oncall_notification_subtitle (
113
+ schedule , multiple_day_shift , maus
119
114
)
120
- multiple_day_shift_no_locale_title = tasks ._get_youre_going_oncall_notification_title (
121
- schedule , seconds_until_going_oncall , multiple_day_shift , maus_no_locale
115
+ multiple_day_shift_no_locale_subtitle = tasks ._get_youre_going_oncall_notification_subtitle (
116
+ schedule , multiple_day_shift , maus_no_locale
122
117
)
123
118
119
+ assert multiple_day_shift_title == f"Your on-call shift starts in { humanized_time_until_going_oncall } "
120
+ assert multiple_day_shift_subtitle == f"2023-07-08 09 h 00 - 2023-07-12 17 h 00\n Schedule { schedule_name } "
124
121
assert (
125
- multiple_day_shift_title
126
- == f"You're going on call in { humanized_time_until_going_oncall } for schedule { schedule_name } , 2023-07-08 09 h 00 - 2023-07-12 17 h 00"
127
- )
128
- assert (
129
- multiple_day_shift_no_locale_title
130
- == f"You're going on call in { humanized_time_until_going_oncall } for schedule { schedule_name } , 7/8/23, 9:00\u202f AM - 7/12/23, 5:00\u202f PM"
122
+ multiple_day_shift_no_locale_subtitle
123
+ == f"7/8/23, 9:00\u202f AM - 7/12/23, 5:00\u202f PM\n Schedule { schedule_name } "
131
124
)
132
125
133
126
127
+ @mock .patch ("apps.mobile_app.tasks._get_youre_going_oncall_notification_subtitle" )
134
128
@mock .patch ("apps.mobile_app.tasks._get_youre_going_oncall_notification_title" )
135
129
@mock .patch ("apps.mobile_app.tasks._construct_fcm_message" )
136
130
@mock .patch ("apps.mobile_app.tasks.APNSPayload" )
@@ -145,16 +139,19 @@ def test_get_youre_going_oncall_fcm_message(
145
139
mock_apns_payload ,
146
140
mock_construct_fcm_message ,
147
141
mock_get_youre_going_oncall_notification_title ,
142
+ mock_get_youre_going_oncall_notification_subtitle ,
148
143
make_organization_and_user ,
149
144
make_schedule ,
150
145
):
151
146
mock_fcm_message = "mncvmnvcmnvcnmvcmncvmn"
152
147
mock_notification_title = "asdfasdf"
148
+ mock_notification_subtitle = f"9:06\u202f AM - 9:06\u202f AM\n Schedule XYZ"
153
149
shift_pk = "mncvmnvc"
154
150
seconds_until_going_oncall = 600
155
151
156
152
mock_construct_fcm_message .return_value = mock_fcm_message
157
153
mock_get_youre_going_oncall_notification_title .return_value = mock_notification_title
154
+ mock_get_youre_going_oncall_notification_subtitle .return_value = mock_notification_subtitle
158
155
159
156
organization , user = make_organization_and_user ()
160
157
user_pk = user .public_primary_key
@@ -177,6 +174,7 @@ def test_get_youre_going_oncall_fcm_message(
177
174
178
175
data = {
179
176
"title" : mock_notification_title ,
177
+ "subtitle" : mock_notification_subtitle ,
180
178
"info_notification_sound_name" : (
181
179
maus .info_notification_sound_name + MobileAppUserSettings .ANDROID_SOUND_NAME_EXTENSION
182
180
),
@@ -191,7 +189,7 @@ def test_get_youre_going_oncall_fcm_message(
191
189
192
190
assert fcm_message == mock_fcm_message
193
191
194
- mock_aps_alert .assert_called_once_with (title = mock_notification_title )
192
+ mock_aps_alert .assert_called_once_with (title = mock_notification_title , subtitle = mock_notification_subtitle )
195
193
mock_critical_sound .assert_called_once_with (
196
194
critical = False , name = maus .info_notification_sound_name + MobileAppUserSettings .IOS_SOUND_NAME_EXTENSION
197
195
)
@@ -205,9 +203,9 @@ def test_get_youre_going_oncall_fcm_message(
205
203
)
206
204
mock_apns_payload .assert_called_once_with (aps = mock_aps .return_value )
207
205
208
- mock_get_youre_going_oncall_notification_title .assert_called_once_with (
209
- schedule , seconds_until_going_oncall , schedule_event , maus
210
- )
206
+ mock_get_youre_going_oncall_notification_subtitle .assert_called_once_with (schedule , schedule_event , maus )
207
+ mock_get_youre_going_oncall_notification_title . assert_called_once_with ( seconds_until_going_oncall )
208
+
211
209
mock_construct_fcm_message .assert_called_once_with (
212
210
tasks .MessageType .INFO , device , notification_thread_id , data , mock_apns_payload .return_value
213
211
)
0 commit comments