From f4ca3310dba11a49950b1d5e6f68f1213773e2dd Mon Sep 17 00:00:00 2001 From: Joshua Hiller Date: Mon, 28 Oct 2024 15:37:30 -0400 Subject: [PATCH] Adjust event streams refresh unit testing to address flakiness --- tests/test_event_streams.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/tests/test_event_streams.py b/tests/test_event_streams.py index 39efafe90..04e541c82 100644 --- a/tests/test_event_streams.py +++ b/tests/test_event_streams.py @@ -45,13 +45,16 @@ def stream_refresh(): avail["body"]["resources"][0]["sessionToken"]["token"] ), 'Date': current_time, 'Connection': 'Keep-Alive' } - stream = requests.get(avail["body"]["resources"][0]["dataFeedURL"], headers=headers, stream=True) - with stream: - result = falcon.refreshActiveStreamSession(app_id=f"{APP_ID}", - action_name="refresh_active_stream_session", - partition=0 - ) - return bool(result["status_code"] in AllowedResponses) + if avail["body"]["resources"]: + stream = requests.get(avail["body"]["resources"][0]["dataFeedURL"], headers=headers, stream=True) + with stream: + result = falcon.refreshActiveStreamSession(app_id=f"{APP_ID}", + action_name="refresh_active_stream_session", + partition=0 + ) + return bool(result["status_code"] in AllowedResponses) + else: + pytest.skip("Rate limited") @staticmethod def stream_refresh_default_action(): @@ -63,13 +66,15 @@ def stream_refresh_default_action(): avail["body"]["resources"][0]["sessionToken"]["token"] ), 'Date': current_time, 'Connection': 'Keep-Alive' } - stream = requests.get(avail["body"]["resources"][0]["dataFeedURL"], headers=headers, stream=True) - with stream: - result = falcon.refreshActiveStreamSession(appId=f"{APP_ID}", - partition="0" - ) - return bool(result["status_code"] in AllowedResponses) - + if avail["body"]["resources"]: + stream = requests.get(avail["body"]["resources"][0]["dataFeedURL"], headers=headers, stream=True) + with stream: + result = falcon.refreshActiveStreamSession(appId=f"{APP_ID}", + partition="0" + ) + return bool(result["status_code"] in AllowedResponses) + else: + pytest.skip("Rate limited") @staticmethod def stream_errors():