Skip to content

Commit

Permalink
Resuse MockQuery and MockContext in other unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Aug 11, 2023
1 parent 7ab7460 commit 49fee79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
3 changes: 3 additions & 0 deletions lib/galaxy/app_unittest_utils/tools_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ def flush(self):
def add(self, object):
self.created_objects.append(object)

def commit(self):
pass


class MockQuery:
def __init__(self, class_objects):
Expand Down
38 changes: 4 additions & 34 deletions test/unit/app/jobs/test_job_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
Type,
)

from galaxy.app_unittest_utils.tools_support import UsesApp
from galaxy.app_unittest_utils.tools_support import (
MockContext,
UsesApp,
)
from galaxy.jobs import (
JobWrapper,
TaskWrapper,
Expand Down Expand Up @@ -134,39 +137,6 @@ def url_to_destination(self):
pass


class MockContext:
def __init__(self, model_objects):
self.expunged_all = False
self.model_objects = model_objects
self.created_objects = []

def expunge_all(self):
self.expunged_all = True

def query(self, clazz):
return MockQuery(self.model_objects.get(clazz))

def flush(self):
pass

def commit(self):
pass

def add(self, object):
self.created_objects.append(object)


class MockQuery:
def __init__(self, class_objects):
self.class_objects = class_objects

def filter_by(self, **kwds):
return Bunch(first=lambda: None)

def get(self, id):
return self.class_objects.get(id, None)


class MockTool:
def __init__(self, app):
self.version_string_cmd = TEST_VERSION_COMMAND
Expand Down

0 comments on commit 49fee79

Please sign in to comment.