mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Move mapping tests into own dir; start refactoring
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
def collection_consists_of_objects(collection, *objects):
|
||||
"""
|
||||
Returns True iff list(collection) == list(objects), where object equality is determined
|
||||
by primary key equality: object1.id == object2.id.
|
||||
"""
|
||||
if len(collection) != len(objects): # False if lengths are different
|
||||
return False
|
||||
if not collection: # True if both are empty
|
||||
return True
|
||||
|
||||
# Sort, then compare each member by its 'id' attribute, which must be its primary key.
|
||||
collection.sort(key=lambda item: item.id)
|
||||
objects = list(objects)
|
||||
objects.sort(key=lambda item: item.id)
|
||||
|
||||
for item1, item2 in zip(collection, objects):
|
||||
if item1.id is None or item2.id is None or item1.id != item2.id:
|
||||
return False
|
||||
return True
|
||||
+1
-21
@@ -72,6 +72,7 @@ from sqlalchemy import (
|
||||
)
|
||||
|
||||
import galaxy.model.mapping as mapping
|
||||
from .common import collection_consists_of_objects
|
||||
|
||||
|
||||
class BaseTest:
|
||||
@@ -7483,27 +7484,6 @@ def get_unique_value():
|
||||
return uuid4().hex
|
||||
|
||||
|
||||
def collection_consists_of_objects(collection, *objects):
|
||||
"""
|
||||
Returns True iff list(collection) == list(objects), where object equality is determined
|
||||
by primary key equality: object1.id == object2.id.
|
||||
"""
|
||||
if len(collection) != len(objects): # False if lengths are different
|
||||
return False
|
||||
if not collection: # True if both are empty
|
||||
return True
|
||||
|
||||
# Sort, then compare each member by its 'id' attribute, which must be its primary key.
|
||||
collection.sort(key=lambda item: item.id)
|
||||
objects = list(objects)
|
||||
objects.sort(key=lambda item: item.id)
|
||||
|
||||
for item1, item2 in zip(collection, objects):
|
||||
if item1.id is None or item2.id is None or item1.id != item2.id:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _run_average_rating_test(session, obj, user, obj_rating_association_factory):
|
||||
# obj has been expunged; to access its deferred properties,
|
||||
# it needs to be added back to the session.
|
||||
Reference in New Issue
Block a user