Skip to content

Commit

Permalink
Fix incorrect assertion in test_create_with_invalid_url
Browse files Browse the repository at this point in the history
Signed-off-by: Cooper Tseng <[email protected]>
  • Loading branch information
brandboat committed Sep 2, 2024
1 parent ba771f7 commit 912b53a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions harvester_e2e_tests/apis/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,17 @@ def test_create_with_invalid_url(api_client, gen_unique_name, wait_timeout):
while endtime > datetime.now():
code, data = api_client.images.get(unique_name)
image_conds = data.get('status', {}).get('conditions', [])
if len(image_conds) > 0:
initialized_cond = next((cond for cond in image_conds if cond.get("type") == "Initialized"), None)

try:
assert initialized_cond is not None
assert initialized_cond.get("status") == "False"
assert "no such host" in initialized_cond.get("message")
break
except AssertionError:
pass
sleep(3)

assert len(image_conds) in (1, 2), f"Got unexpected image conditions!\n{data}"
assert "Initialized" == image_conds[-1].get("type")
assert "False" == image_conds[-1].get("status")
assert "no such host" in image_conds[-1].get("message")
assert endtime > datetime.now(), "Timeout reached without meeting the expected conditions."

api_client.images.delete(unique_name)

0 comments on commit 912b53a

Please sign in to comment.