当前位置: 首页>>代码示例>>Python>>正文


Python HistoryManager.annotate方法代码示例

本文整理汇总了Python中galaxy.managers.histories.HistoryManager.annotate方法的典型用法代码示例。如果您正苦于以下问题:Python HistoryManager.annotate方法的具体用法?Python HistoryManager.annotate怎么用?Python HistoryManager.annotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在galaxy.managers.histories.HistoryManager的用法示例。


在下文中一共展示了HistoryManager.annotate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HistoryManagerTestCase

# 需要导入模块: from galaxy.managers.histories import HistoryManager [as 别名]
# 或者: from galaxy.managers.histories.HistoryManager import annotate [as 别名]
class HistoryManagerTestCase(BaseTestCase):

    def set_up_managers(self):
        super(HistoryManagerTestCase, self).set_up_managers()
        self.history_manager = HistoryManager(self.app)
        self.hda_manager = hdas.HDAManager(self.app)

    def add_hda_to_history(self, history, **kwargs):
        dataset = self.hda_manager.dataset_manager.create()
        hda = self.hda_manager.create(history=history, dataset=dataset, **kwargs)
        return hda

    def test_base(self):
        user2 = self.user_manager.create(**user2_data)
        user3 = self.user_manager.create(**user3_data)

        self.log("should be able to create a new history")
        history1 = self.history_manager.create(name='history1', user=user2)
        self.assertIsInstance(history1, model.History)
        self.assertEqual(history1.name, 'history1')
        self.assertEqual(history1.user, user2)
        self.assertEqual(history1, self.trans.sa_session.query(model.History).get(history1.id))
        self.assertEqual(history1,
            self.trans.sa_session.query(model.History).filter(model.History.name == 'history1').one())
        self.assertEqual(history1,
            self.trans.sa_session.query(model.History).filter(model.History.user == user2).one())

        history2 = self.history_manager.copy(history1, user=user3)

        self.log("should be able to query")
        histories = self.trans.sa_session.query(model.History).all()
        self.assertEqual(self.history_manager.one(filters=(model.History.id == history1.id)), history1)
        self.assertEqual(self.history_manager.list(), histories)
        self.assertEqual(self.history_manager.by_id(history1.id), history1)
        self.assertEqual(self.history_manager.by_ids([history2.id, history1.id]), [history2, history1])

        self.log("should be able to limit and offset")
        self.assertEqual(self.history_manager.list(limit=1), histories[0:1])
        self.assertEqual(self.history_manager.list(offset=1), histories[1:])
        self.assertEqual(self.history_manager.list(limit=1, offset=1), histories[1:2])

        self.assertEqual(self.history_manager.list(limit=0), [])
        self.assertEqual(self.history_manager.list(offset=3), [])

        self.log("should be able to order")
        history3 = self.history_manager.create(name="history3", user=user2)
        name_first_then_time = (model.History.name, sqlalchemy.desc(model.History.create_time))
        self.assertEqual(self.history_manager.list(order_by=name_first_then_time),
            [history2, history1, history3])

    def test_copy(self):
        user2 = self.user_manager.create(**user2_data)
        user3 = self.user_manager.create(**user3_data)

        self.log("should be able to copy a history (and it's hdas)")
        history1 = self.history_manager.create(name='history1', user=user2)
        tags = [u'tag-one']
        annotation = u'history annotation'
        self.history_manager.set_tags(history1, tags, user=user2)
        self.history_manager.annotate(history1, annotation, user=user2)

        hda = self.add_hda_to_history(history1, name='wat')
        hda_tags = [u'tag-one', u'tag-two']
        hda_annotation = u'annotation'
        self.hda_manager.set_tags(hda, hda_tags, user=user2)
        self.hda_manager.annotate(hda, hda_annotation, user=user2)

        history2 = self.history_manager.copy(history1, user=user3)
        self.assertIsInstance(history2, model.History)
        self.assertEqual(history2.user, user3)
        self.assertEqual(history2, self.trans.sa_session.query(model.History).get(history2.id))
        self.assertEqual(history2.name, history1.name)
        self.assertNotEqual(history2, history1)

        copied_hda = history2.datasets[0]
        copied_hda_tags = self.hda_manager.get_tags(copied_hda)
        self.assertEqual(sorted(hda_tags), sorted(copied_hda_tags))
        copied_hda_annotation = self.hda_manager.annotation(copied_hda)
        self.assertEqual(hda_annotation, copied_hda_annotation)

    def test_has_user(self):
        owner = self.user_manager.create(**user2_data)
        non_owner = self.user_manager.create(**user3_data)

        item1 = self.history_manager.create(user=owner)
        item2 = self.history_manager.create(user=owner)
        self.history_manager.create(user=non_owner)

        self.log("should be able to list items by user")
        user_histories = self.history_manager.by_user(owner)
        self.assertEqual(user_histories, [item1, item2])

    def test_ownable(self):
        owner = self.user_manager.create(**user2_data)
        non_owner = self.user_manager.create(**user3_data)

        item1 = self.history_manager.create(user=owner)

        self.log("should be able to poll whether a given user owns an item")
        self.assertTrue(self.history_manager.is_owner(item1, owner))
#.........这里部分代码省略.........
开发者ID:bwlang,项目名称:galaxy,代码行数:103,代码来源:test_HistoryManager.py


注:本文中的galaxy.managers.histories.HistoryManager.annotate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。