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


Python Fixtures.create_2方法代码示例

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


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

示例1: test_incremental_tasks

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create_2 [as 别名]
    def test_incremental_tasks(self):
        """ Test incremental SCHED strategy - second TaskRun receives first gaven answer"""

        Fixtures.create_2(sched='incremental')

        # Del previous TaskRuns
        self.del_task_runs()

        # Register
        self.register(fullname=self.user.fullname, username=self.user.username,
                      password=self.user.password)
        self.register(fullname="Marie Doe", username="mariedoe", password="dr0wss4p")
        self.signin()

        # Get the only task with no runs!
        res = self.app.get('api/app/1/newtask')
        data = json.loads(res.data)
        # Check that we received a clean Task
        assert data.get('info'), data
        assert not data.get('info').get('last_answer')

        # Submit an Answer for the assigned task
        tr = dict(app_id=data['app_id'], task_id=data['id'], info={'answer': 'No'})
        tr = json.dumps(tr)

        self.app.post('/api/taskrun', data=tr)
        # No more tasks available for this user!
        res = self.app.get('api/app/1/newtask')
        data = json.loads(res.data)
        assert not data

        #### Get the only task now with an answer as Anonimous!
        self.signout()
        res = self.app.get('api/app/1/newtask')
        data = json.loads(res.data)

        # Check that we received a Task with answer
        assert data.get('info'), data
        assert data.get('info').get('last_answer').get('answer') == 'No'

        # Submit a second Answer as Anonimous
        tr = dict(app_id=data['app_id'], task_id=data['id'],
                  info={'answer': 'No No'})
        tr = json.dumps(tr)

        self.app.post('/api/taskrun', data=tr)

        #### Get the only task now with an answer as User2!
        self.signin(email="[email protected]", password="dr0wss4p")
        res = self.app.get('api/app/1/newtask')
        data = json.loads(res.data)

        # Check that we received a Task with answer
        assert data.get('info'), data
        assert data.get('info').get('last_answer').get('answer') == 'No No'
开发者ID:rkyymmt,项目名称:pybossa,代码行数:57,代码来源:test_sched_2.py


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