Skip to content

Commit

Permalink
fix get_alert_by_id and account for cache dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorcary committed Sep 4, 2024
1 parent 2e5af12 commit 7743480
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/api2/test_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def get_alert_by_id(alert_id):
return next(filter(lambda alert: alert["id"] == alert_id, call("alert.list")))
return next(filter(lambda alert: alert["id"] == alert_id, call("alert.list")), None)


@pytest.mark.dependency(name="degrade_pool")
Expand All @@ -30,6 +30,7 @@ def test_verify_the_pool_is_degraded(request):


@pytest.mark.timeout(120)
@pytest.mark.dependency(name="set_alert_id")
def test_wait_for_the_alert_and_get_the_id(request):
depends(request, ["degrade_pool"], scope="session")
call("alert.process_alerts")
Expand All @@ -46,15 +47,15 @@ def test_wait_for_the_alert_and_get_the_id(request):


def test_verify_the_alert_is_dismissed(request):
depends(request, ["degrade_pool"], scope="session")
depends(request, ["degrade_pool", "set_alert_id"], scope="session")
alert_id = request.config.cache.get("alert/alert_id", "Not a valid id")
call("alert.dismiss", alert_id)
alert = get_alert_by_id(alert_id)
assert alert["dismissed"] is True, alert


def test_verify_the_alert_is_restored(request):
depends(request, ["degrade_pool"], scope="session")
depends(request, ["degrade_pool", "set_alert_id"], scope="session")
alert_id = request.config.cache.get("alert/alert_id", "Not a valid id")
call("alert.restore", alert_id)
alert = get_alert_by_id(alert_id)
Expand All @@ -75,7 +76,7 @@ def test_verify_the_pool_is_not_degraded(request):

@pytest.mark.timeout(120)
def test_wait_for_the_alert_to_disappear(request):
depends(request, ["degrade_pool"], scope="session")
depends(request, ["degrade_pool", "set_alert_id"], scope="session")
alert_id = request.config.cache.get("alert/alert_id", "Not a valid id")
while get_alert_by_id(alert_id) is not None:
sleep(1)

0 comments on commit 7743480

Please sign in to comment.