Skip to content

Commit 37707e3

Browse files
committed
Added offline user alert set status test
1 parent e5585e1 commit 37707e3

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tests/unit/test_user_alert.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,28 @@ def test_user_alert_status_offline() -> None:
191191
_run.alerts = [_alert.id]
192192
_run.commit()
193193

194-
sender(_alert._local_staging_file.parents[1], 1, 10, ["folders", "runs", "alerts"])
194+
_id_mapping = sender(_alert._local_staging_file.parents[1], 1, 10, ["folders", "runs", "alerts"])
195195
time.sleep(1)
196+
197+
# Get online aler, check status is not set
198+
_online_alert = UserAlert(_id_mapping.get(_alert.id))
199+
assert not _online_alert.get_status(run_id=_id_mapping.get(_run.id))
196200

197201
_alert.set_status(_run.id, "critical")
198202
_alert.commit()
199-
import pdb; pdb.set_trace()
200203
time.sleep(1)
204+
205+
# Check online status is still not set as change has not been sent
206+
_online_alert.refresh()
207+
assert not _online_alert.get_status(run_id=_id_mapping.get(_run.id))
208+
209+
sender(_alert._local_staging_file.parents[1], 1, 10, ["alerts"])
210+
time.sleep(1)
211+
212+
# Check online status has been updated
213+
_online_alert.refresh()
214+
assert _online_alert.get_status(run_id=_id_mapping.get(_run.id)) == "critical"
215+
201216
_run.delete()
202217
_folder.delete(recursive=True, runs_only=False, delete_runs=True)
203218
_alert.delete()

0 commit comments

Comments
 (0)