Skip to content

Commit

Permalink
Merge pull request #96 from kysrpex/add-id-mock-galaxy-user
Browse files Browse the repository at this point in the history
Add id to `mock_galaxy.User`
  • Loading branch information
nuwang authored May 4, 2023
2 parents e85243a + f981ee5 commit 053f106
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tpv/commands/test/mock_galaxy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import hashlib

from galaxy.model import mapping
from galaxy.job_metrics import JobMetrics
from galaxy.jobs import JobConfiguration
Expand Down Expand Up @@ -76,10 +78,13 @@ def __init__(self, job_conf=None, create_model=False):


class User:
def __init__(self, username, email, roles=[]):
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 int(
hashlib.sha256(f"{self.username}".encode("utf-8")).hexdigest(), 16
) % 1000000

def all_roles(self):
"""
Expand Down

0 comments on commit 053f106

Please sign in to comment.