Fix flakiness in team sync tests
This commit is contained in:
parent
b26bd3c9c5
commit
bdd07d4f39
1 changed files with 13 additions and 9 deletions
|
@ -1,5 +1,4 @@
|
|||
from datetime import timedelta
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -211,8 +210,6 @@ def test_sync_teams_to_groups(app):
|
|||
|
||||
# Call to sync all teams.
|
||||
fake_auth = FakeUsers([])
|
||||
|
||||
time.sleep(1)
|
||||
sync_teams_to_groups(fake_auth, timedelta(seconds=1))
|
||||
|
||||
# Ensure the team was synced.
|
||||
|
@ -221,16 +218,23 @@ def test_sync_teams_to_groups(app):
|
|||
assert updated_sync_info.transaction_id != sync_team_info.transaction_id
|
||||
|
||||
# Set the stale threshold to a high amount and ensure the team is not resynced.
|
||||
time.sleep(1)
|
||||
current_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
||||
current_info.last_updated = datetime.now() - timedelta(seconds=2)
|
||||
current_info.save()
|
||||
|
||||
sync_teams_to_groups(fake_auth, timedelta(seconds=120))
|
||||
|
||||
third_sync_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
||||
assert third_sync_info.last_updated == updated_sync_info.last_updated
|
||||
assert third_sync_info.last_updated == current_info.last_updated
|
||||
assert third_sync_info.transaction_id == updated_sync_info.transaction_id
|
||||
|
||||
# Set the stale threshold to -120 seconds, and ensure the team is resynced.
|
||||
time.sleep(1)
|
||||
sync_teams_to_groups(fake_auth, timedelta(seconds=-120))
|
||||
# Set the stale threshold to 10 seconds, and ensure the team is resynced, after making it
|
||||
# "updated" 20s ago.
|
||||
current_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
||||
current_info.last_updated = datetime.now() - timedelta(seconds=20)
|
||||
current_info.save()
|
||||
|
||||
sync_teams_to_groups(fake_auth, timedelta(seconds=10))
|
||||
|
||||
fourth_sync_info = model.team.get_team_sync_information('buynlarge', 'synced')
|
||||
assert fourth_sync_info.transaction_id != updated_sync_info.transaction_id
|
||||
|
|
Reference in a new issue