Skip to content

Commit

Permalink
Derive id from username whenever not given.
Browse files Browse the repository at this point in the history
  • Loading branch information
kysrpex committed May 4, 2023
1 parent c387a39 commit f981ee5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tpv/commands/test/mock_galaxy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import random
import hashlib

from galaxy.model import mapping
from galaxy.job_metrics import JobMetrics
Expand Down Expand Up @@ -82,7 +82,9 @@ def __init__(self, username, email, roles=[], id=None):
self.username = username
self.email = email
self.roles = [Role(name) for name in roles]
self.id = id or random.randint(1, 1000000)
self.id = id or int(
hashlib.sha256(f"{self.username}".encode("utf-8")).hexdigest(), 16
) % 1000000

def all_roles(self):
"""
Expand Down

0 comments on commit f981ee5

Please sign in to comment.