Skip to content

Commit

Permalink
Adjust event streams refresh unit testing to address flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
jshcodes committed Oct 30, 2024
1 parent 732efbc commit 4e687ab
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/test_event_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def stream_refresh():
"""refresh_active_stream"""
avail = falcon.listAvailableStreamsOAuth2(parameters={"appId": f"{APP_ID}"})
current_time = datetime.now(timezone.utc).strftime('%a, %d %b %Y %H:%M:%S +0000')
headers = {
'Authorization': 'Token %s' % (
avail["body"]["resources"][0]["sessionToken"]["token"]
), 'Date': current_time, 'Connection': 'Keep-Alive'
}
if avail["body"]["resources"]:
headers = {
'Authorization': 'Token %s' % (
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}",
Expand All @@ -61,12 +61,13 @@ def stream_refresh_default_action():
"""refresh_active_stream"""
avail = falcon.listAvailableStreamsOAuth2(parameters={"appId": f"{APP_ID}"})
current_time = datetime.now(timezone.utc).strftime('%a, %d %b %Y %H:%M:%S +0000')
headers = {
'Authorization': 'Token %s' % (
avail["body"]["resources"][0]["sessionToken"]["token"]
), 'Date': current_time, 'Connection': 'Keep-Alive'
}
if avail["body"]["resources"]:
headers = {
'Authorization': 'Token %s' % (
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}",
Expand Down

0 comments on commit 4e687ab

Please sign in to comment.