forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify rating classes initialization (see note)
1. Remove id parameter from constructor (this is created by the db). 2. Remove `item` instance attribute: it's not used and is meaningless. 3. Make user and item parameters in the constructor required: a rating cannot exist without a rater or the item being rated. 4. For the same reason as in #2, make the `set_item()` method private and only call it from the constructor. 5. Simplify mapping test: just use the constructor.
- Loading branch information
Showing
4 changed files
with
28 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,52 +130,50 @@ def persist_and_check_annotation(annotation_class, **kwds): | |
def test_ratings(self): | ||
model = self.model | ||
|
||
u = model.User(email="[email protected]", password="password") | ||
user_email = "[email protected]" | ||
u = model.User(email=user_email, password="password") | ||
self.persist(u) | ||
|
||
def persist_and_check_rating(rating_class, **kwds): | ||
rating_association = rating_class() | ||
rating_association.rating = 5 | ||
rating_association.user = u | ||
for key, value in kwds.items(): | ||
setattr(rating_association, key, value) | ||
def persist_and_check_rating(rating_class, item): | ||
rating = 5 | ||
rating_association = rating_class(u, item, rating) | ||
self.persist(rating_association) | ||
self.expunge() | ||
stored_annotation = self.query(rating_class).all()[0] | ||
assert stored_annotation.rating == 5 | ||
assert stored_annotation.user.email == "[email protected]" | ||
stored_rating = self.query(rating_class).all()[0] | ||
assert stored_rating.rating == rating | ||
assert stored_rating.user.email == user_email | ||
|
||
sw = model.StoredWorkflow() | ||
sw.user = u | ||
self.persist(sw) | ||
persist_and_check_rating(model.StoredWorkflowRatingAssociation, stored_workflow=sw) | ||
persist_and_check_rating(model.StoredWorkflowRatingAssociation, sw) | ||
|
||
h = model.History(name="History for Rating", user=u) | ||
self.persist(h) | ||
persist_and_check_rating(model.HistoryRatingAssociation, history=h) | ||
persist_and_check_rating(model.HistoryRatingAssociation, h) | ||
|
||
d1 = model.HistoryDatasetAssociation(extension="txt", history=h, create_dataset=True, sa_session=model.session) | ||
self.persist(d1) | ||
persist_and_check_rating(model.HistoryDatasetAssociationRatingAssociation, hda=d1) | ||
persist_and_check_rating(model.HistoryDatasetAssociationRatingAssociation, d1) | ||
|
||
page = model.Page() | ||
page.user = u | ||
self.persist(page) | ||
persist_and_check_rating(model.PageRatingAssociation, page=page) | ||
persist_and_check_rating(model.PageRatingAssociation, page) | ||
|
||
visualization = model.Visualization() | ||
visualization.user = u | ||
self.persist(visualization) | ||
persist_and_check_rating(model.VisualizationRatingAssociation, visualization=visualization) | ||
persist_and_check_rating(model.VisualizationRatingAssociation, visualization) | ||
|
||
dataset_collection = model.DatasetCollection(collection_type="paired") | ||
history_dataset_collection = model.HistoryDatasetCollectionAssociation(collection=dataset_collection) | ||
self.persist(history_dataset_collection) | ||
persist_and_check_rating(model.HistoryDatasetCollectionRatingAssociation, history_dataset_collection=history_dataset_collection) | ||
persist_and_check_rating(model.HistoryDatasetCollectionRatingAssociation, history_dataset_collection) | ||
|
||
library_dataset_collection = model.LibraryDatasetCollectionAssociation(collection=dataset_collection) | ||
self.persist(library_dataset_collection) | ||
persist_and_check_rating(model.LibraryDatasetCollectionRatingAssociation, library_dataset_collection=library_dataset_collection) | ||
persist_and_check_rating(model.LibraryDatasetCollectionRatingAssociation, library_dataset_collection) | ||
|
||
def test_display_name(self): | ||
|
||
|