本文整理汇总了Python中galaxy.managers.histories.HistoryManager.update方法的典型用法代码示例。如果您正苦于以下问题:Python HistoryManager.update方法的具体用法?Python HistoryManager.update怎么用?Python HistoryManager.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类galaxy.managers.histories.HistoryManager
的用法示例。
在下文中一共展示了HistoryManager.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HistoryFiltersTestCase
# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import update [as 别名]
class HistoryFiltersTestCase(BaseTestCase):
def set_up_managers(self):
super(HistoryFiltersTestCase, self).set_up_managers()
self.history_manager = HistoryManager(self.app)
self.filter_parser = HistoryFilters(self.app)
# ---- functional and orm filter splitting and resolution
def test_parse_filters(self):
filters = self.filter_parser.parse_filters([
('name', 'eq', 'wot'),
('deleted', 'eq', 'True'),
('annotation', 'has', 'hrrmm')
])
self.log('both orm and fn filters should be parsed and returned')
self.assertEqual(len(filters), 3)
self.log('values should be parsed')
self.assertIsInstance(filters[1].right, sqlalchemy.sql.elements.True_)
def test_parse_filters_invalid_filters(self):
self.log('should error on non-column attr')
self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
('merp', 'eq', 'wot'),
])
self.log('should error on non-whitelisted attr')
self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
('user_id', 'eq', 'wot'),
])
self.log('should error on non-whitelisted op')
self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
('name', 'lt', 'wot'),
])
self.log('should error on non-listed fn op')
self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
('annotation', 'like', 'wot'),
])
self.log('should error on val parsing error')
self.assertRaises(exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [
('deleted', 'eq', 'true'),
])
def test_orm_filter_parsing(self):
user2 = self.user_manager.create(**user2_data)
history1 = self.history_manager.create(name='history1', user=user2)
history2 = self.history_manager.create(name='history2', user=user2)
history3 = self.history_manager.create(name='history3', user=user2)
filters = self.filter_parser.parse_filters([
('name', 'like', 'history%'),
])
histories = self.history_manager.list(filters=filters)
# for h in histories:
# print h.name
self.assertEqual(histories, [history1, history2, history3])
filters = self.filter_parser.parse_filters([('name', 'like', '%2'), ])
self.assertEqual(self.history_manager.list(filters=filters), [history2])
filters = self.filter_parser.parse_filters([('name', 'eq', 'history2'), ])
self.assertEqual(self.history_manager.list(filters=filters), [history2])
self.history_manager.update(history1, dict(deleted=True))
filters = self.filter_parser.parse_filters([('deleted', 'eq', 'True'), ])
self.assertEqual(self.history_manager.list(filters=filters), [history1])
filters = self.filter_parser.parse_filters([('deleted', 'eq', 'False'), ])
self.assertEqual(self.history_manager.list(filters=filters), [history2, history3])
self.assertEqual(self.history_manager.list(), [history1, history2, history3])
self.history_manager.update(history3, dict(deleted=True))
self.history_manager.update(history1, dict(importable=True))
self.history_manager.update(history2, dict(importable=True))
filters = self.filter_parser.parse_filters([
('deleted', 'eq', 'True'),
('importable', 'eq', 'True'),
])
self.assertEqual(self.history_manager.list(filters=filters), [history1])
self.assertEqual(self.history_manager.list(), [history1, history2, history3])
def test_fn_filter_parsing(self):
user2 = self.user_manager.create(**user2_data)
history1 = self.history_manager.create(name='history1', user=user2)
history2 = self.history_manager.create(name='history2', user=user2)
history3 = self.history_manager.create(name='history3', user=user2)
filters = self.filter_parser.parse_filters([('annotation', 'has', 'no play'), ])
anno_filter = filters[0]
history3.add_item_annotation(self.trans.sa_session, user2, history3, "All work and no play")
self.trans.sa_session.flush()
self.assertTrue(anno_filter(history3))
self.assertFalse(anno_filter(history2))
self.assertEqual(self.history_manager.list(filters=filters), [history3])
self.log('should allow combinations of orm and fn filters')
self.history_manager.update(history3, dict(importable=True))
self.history_manager.update(history2, dict(importable=True))
history1.add_item_annotation(self.trans.sa_session, user2, history1, "All work and no play")
#.........这里部分代码省略.........
示例2: HistoryManagerTestCase
# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import update [as 别名]
#.........这里部分代码省略.........
anon_history2 = self.history_manager.create(user=anon_user)
self.trans.set_history(anon_history2)
self.assertTrue(self.history_manager.is_owner(anon_history2, anon_user, current_history=self.trans.history))
self.assertTrue(self.history_manager.is_accessible(anon_history2, anon_user, current_history=self.trans.history))
self.log("should not allow owner or access for anon user on someone elses history")
owner = self.user_manager.create(**user2_data)
someone_elses = self.history_manager.create(user=owner)
self.assertFalse(self.history_manager.is_owner(someone_elses, anon_user, current_history=self.trans.history))
self.assertFalse(self.history_manager.is_accessible(someone_elses, anon_user, current_history=self.trans.history))
self.log("should allow access for anon user if the history is published or importable")
self.history_manager.make_importable(someone_elses)
self.assertTrue(self.history_manager.is_accessible(someone_elses, anon_user, current_history=self.trans.history))
self.history_manager.publish(someone_elses)
self.assertTrue(self.history_manager.is_accessible(someone_elses, anon_user, current_history=self.trans.history))
def test_delete_and_purge(self):
user2 = self.user_manager.create(**user2_data)
self.trans.set_user(user2)
history1 = self.history_manager.create(name='history1', user=user2)
self.trans.set_history(history1)
self.log("should allow deletion and undeletion")
self.assertFalse(history1.deleted)
self.history_manager.delete(history1)
self.assertTrue(history1.deleted)
self.history_manager.undelete(history1)
self.assertFalse(history1.deleted)
self.log("should allow purging")
history2 = self.history_manager.create(name='history2', user=user2)
self.history_manager.purge(history2)
self.assertTrue(history2.deleted)
self.assertTrue(history2.purged)
def test_current(self):
user2 = self.user_manager.create(**user2_data)
self.trans.set_user(user2)
history1 = self.history_manager.create(name='history1', user=user2)
self.trans.set_history(history1)
history2 = self.history_manager.create(name='history2', user=user2)
self.log("should be able to set or get the current history for a user")
self.assertEqual(self.history_manager.get_current(self.trans), history1)
self.assertEqual(self.history_manager.set_current(self.trans, history2), history2)
self.assertEqual(self.history_manager.get_current(self.trans), history2)
self.assertEqual(self.history_manager.set_current_by_id(self.trans, history1.id), history1)
self.assertEqual(self.history_manager.get_current(self.trans), history1)
def test_most_recently_used(self):
user2 = self.user_manager.create(**user2_data)
self.trans.set_user(user2)
history1 = self.history_manager.create(name='history1', user=user2)
self.trans.set_history(history1)
history2 = self.history_manager.create(name='history2', user=user2)
self.log("should be able to get the most recently used (updated) history for a given user")
self.assertEqual(self.history_manager.most_recent(user2), history2)
self.history_manager.update(history1, {'name': 'new name'})
self.assertEqual(self.history_manager.most_recent(user2), history1)
def test_rating(self):
user2 = self.user_manager.create(**user2_data)
manager = self.history_manager
item = manager.create(name='history1', user=user2)
self.log("should properly handle no ratings")
self.assertEqual(manager.rating(item, user2), None)
self.assertEqual(manager.ratings(item), [])
self.assertEqual(manager.ratings_avg(item), 0)
self.assertEqual(manager.ratings_count(item), 0)
self.log("should allow rating by user")
manager.rate(item, user2, 5)
self.assertEqual(manager.rating(item, user2), 5)
self.assertEqual(manager.ratings(item), [5])
self.assertEqual(manager.ratings_avg(item), 5)
self.assertEqual(manager.ratings_count(item), 1)
self.log("should allow updating")
manager.rate(item, user2, 4)
self.assertEqual(manager.rating(item, user2), 4)
self.assertEqual(manager.ratings(item), [4])
self.assertEqual(manager.ratings_avg(item), 4)
self.assertEqual(manager.ratings_count(item), 1)
self.log("should reflect multiple reviews")
user3 = self.user_manager.create(**user3_data)
self.assertEqual(manager.rating(item, user3), None)
manager.rate(item, user3, 1)
self.assertEqual(manager.rating(item, user3), 1)
self.assertEqual(manager.ratings(item), [4, 1])
self.assertEqual(manager.ratings_avg(item), 2.5)
self.assertEqual(manager.ratings_count(item), 2)