Don't reuse used oauth_ids in populate.py (#1062)

* Fix `populate.py` from using an `oauth_id` twice.
selenium-screenshot-testing
Kevin Chung 2019-07-16 21:52:39 -04:00 committed by GitHub
parent 1c9e36fa8f
commit bf05b30d56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -279,6 +279,7 @@ if __name__ == '__main__':
# Generating Teams
print("GENERATING TEAMS")
used = []
used_oauth_ids = []
count = 0
while count < TEAM_AMOUNT:
name = gen_team_name()
@ -291,7 +292,11 @@ if __name__ == '__main__':
if random_chance():
team.affiliation = gen_affiliation()
if random_chance():
team.oauth_id = random.randint(1, 1000)
oauth_id = random.randint(1, 1000)
while oauth_id in used_oauth_ids:
oauth_id = random.randint(1, 1000)
used_oauth_ids.append(oauth_id)
team.oauth_id = oauth_id
db.session.add(team)
count += 1
@ -301,6 +306,7 @@ if __name__ == '__main__':
# Generating Users
print("GENERATING USERS")
used = []
used_oauth_ids = []
count = 0
while count < USER_AMOUNT:
name = gen_name()
@ -316,7 +322,11 @@ if __name__ == '__main__':
if random_chance():
user.affiliation = gen_affiliation()
if random_chance():
user.oauth_id = random.randint(1, 1000)
oauth_id = random.randint(1, 1000)
while oauth_id in used_oauth_ids:
oauth_id = random.randint(1, 1000)
used_oauth_ids.append(oauth_id)
user.oauth_id = oauth_id
if mode == 'teams':
user.team_id = random.randint(1, TEAM_AMOUNT)
db.session.add(user)