• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Tasks类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tasks.models.Tasks的典型用法代码示例。如果您正苦于以下问题:Python Tasks类的具体用法?Python Tasks怎么用?Python Tasks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_update_quality_game_with_new_violation

 def test_update_quality_game_with_new_violation(self):
     """Test update quality game with new violation"""
     project = factories.ProjectFactory()
     Tasks.save({
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() - timedelta(hours=5),
         'commit': {
             'branch': 'test',
             'author': 'test',
             'inner': [{'author': {'url': 'test'}}]
         },
         'violations': [],
     })
     project.update_quality_game({
         'project': project.name,
         'success_percent': 15,
         'status': STATUS_SUCCESS,
         'created': datetime.now(),
         'commit': {
             'branch': 'test',
             'author': 'test',
             'inner': [{'author': {'url': 'test'}}]
         },
         'violations': [
             {'name': 'cat', 'success_percent': 15},
         ],
     })
     project.quality_game['violations']['cat']['test']['value']\
         .should.be.equal(1)
开发者ID:michaeljoseph,项目名称:coviolations_web,代码行数:31,代码来源:test_models.py


示例2: test_fail_on_travis_api_error

 def test_fail_on_travis_api_error(self):
     """Test fail on travis api error"""
     travis_ci.requests.get.side_effect = Exception
     data = self._create_task()
     with LogCapture() as log_capture:
         travis_ci.travis_ci_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(0)
开发者ID:coviolations,项目名称:coviolations_web,代码行数:8,代码来源:test_travis_ci.py


示例3: test_fail_if_already_exists

 def test_fail_if_already_exists(self):
     """Test fail if job already exists"""
     self._create_task()
     data = self._create_task()
     with LogCapture() as log_capture:
         travis_ci.travis_ci_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(1)
开发者ID:coviolations,项目名称:coviolations_web,代码行数:8,代码来源:test_travis_ci.py


示例4: test_get_badge_with_filtering

 def test_get_badge_with_filtering(self):
     """Test get badge with filtering"""
     project = factories.ProjectFactory.create()
     Tasks.save({
         'status': const.STATUS_SUCCESS,
         'project': project.name,
         'commit': {'branch': 'test'}
     })
     self._get_and_assert(project.name, 'success', '?branch=test')
开发者ID:coviolations,项目名称:coviolations_web,代码行数:9,代码来源:test_views.py


示例5: test_success

 def test_success(self):
     """Test redirect to success badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'success')
开发者ID:coviolations,项目名称:coviolations_web,代码行数:9,代码来源:test_views.py


示例6: test_get_success_percents

 def test_get_success_percents(self):
     """Test get success percents"""
     project = factories.ProjectFactory()
     Tasks.save({
         'project': project.name,
         'commit': {'branch': 'branch'},
         'success_percent': 92,
     })
     project.get_success_percents(10).should.be.equal([92])
开发者ID:coviolations,项目名称:coviolations_web,代码行数:9,代码来源:test_models.py


示例7: test_fail

 def test_fail(self):
     """Test redirect to fail badge"""
     project = factories.ProjectFactory.create()
     Tasks.insert({
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_FAILED,
         'project': project.name,
     })
     self._get_and_assert(project.name, 'fail')
开发者ID:coviolations,项目名称:coviolations_web,代码行数:9,代码来源:test_views.py


示例8: test_get_neutral_trend

 def test_get_neutral_trend(self):
     """Test get neutral trend"""
     project = factories.ProjectFactory()
     Tasks.save({
         'project': project.name,
         'commit': {'branch': 'branch'},
         'success_percent': 0,
     })
     project.get_trend().should.be.equal(0)
开发者ID:coviolations,项目名称:coviolations_web,代码行数:9,代码来源:test_models.py


示例9: test_get_negative_trend

 def test_get_negative_trend(self):
     """Test get negative trend"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'commit': {'branch': 'branch'},
         'success_percent': n,
         'created': num,
     } for num, n in enumerate(range(5, 1, -1))])
     project.get_trend().should.be.lower_than(0)
开发者ID:coviolations,项目名称:coviolations_web,代码行数:10,代码来源:test_models.py


示例10: _create_task

 def _create_task(self):
     """Create task"""
     task_id = Tasks.save({
         'project': 'test',
         'service': {
             'name': 'travis_ci',
             'job_id': 15,
         }
     })
     return Tasks.find_one(task_id)
开发者ID:coviolations,项目名称:coviolations_web,代码行数:10,代码来源:test_travis_ci.py


示例11: test_success

 def test_success(self):
     """Test success"""
     task_id = Tasks.save({
         'project': 'test',
         'service': {
             'name': 'token',
             'token': self.project.token,
         }
     })
     data = Tasks.find_one(task_id)
     task_id.should.be.equal(token_service(data))
开发者ID:coviolations,项目名称:coviolations_web,代码行数:11,代码来源:test_token.py


示例12: test_update_week_statistic

 def test_update_week_statistic(self):
     """Test update week statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(days=day),
     } for day in range(7)])
     project.update_week_statistic()
     len(project.week_statistic).should.be.ok
开发者ID:coviolations,项目名称:coviolations_web,代码行数:11,代码来源:test_models.py


示例13: test_update_day_time_statistic

 def test_update_day_time_statistic(self):
     """Test update day time statistic"""
     project = factories.ProjectFactory()
     Tasks.insert([{
         'project': project.name,
         'success_percent': 10,
         'status': STATUS_SUCCESS,
         'created': datetime.now() + timedelta(hours=4 * part),
     } for part in range(6)])
     project.update_day_time_statistic()
     len(project.day_time_statistic).should.be.ok
开发者ID:coviolations,项目名称:coviolations_web,代码行数:11,代码来源:test_models.py


示例14: test_unknown_because_last_task_not_finished

 def test_unknown_because_last_task_not_finished(self):
     """Test unknown because not tasks performed"""
     project = factories.ProjectFactory.create()
     Tasks.insert([{
         'created': datetime(2010, 10, 10),
         'status': const.STATUS_SUCCESS,
         'project': project.name,
     }, {
         'created': datetime(2011, 11, 11),
         'status': const.STATUS_NEW,
         'project': project.name,
     }])
     self._get_and_assert(project.name, 'unknown')
开发者ID:coviolations,项目名称:coviolations_web,代码行数:13,代码来源:test_views.py


示例15: test_fail_on_wrong_project

 def test_fail_on_wrong_project(self):
     """Test fail on wrong project"""
     travis_ci.requests.get.return_value = MagicMock(
         json=MagicMock(return_value={
             'repository_id': 2,
             'slug': 'wrong',
         })
     )
     data = self._create_task()
     with LogCapture() as log_capture:
         travis_ci.travis_ci_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(0)
开发者ID:coviolations,项目名称:coviolations_web,代码行数:13,代码来源:test_travis_ci.py


示例16: test_project_branches

 def test_project_branches(self):
     """Test getting project branches"""
     project = factories.ProjectFactory()
     Tasks.insert([{'project': project.name, 'commit': {
         'branch': 'master',
     }}, {'project': project.name, 'commit': {
         'branch': 'develop',
     }}, {'project': project.name, 'commit': {
         'branch': 'master',
     }}, {'project': project.name, 'commit': {
         'branch': 'develop',
     }}])
     set(project.branches).should.be.equal({'master', 'develop'})
开发者ID:coviolations,项目名称:coviolations_web,代码行数:13,代码来源:test_models.py


示例17: test_fail_with_wrong_project

 def test_fail_with_wrong_project(self):
     """Test fail with wrong project"""
     task_id = Tasks.save({
         'project': 'test',
         'service': {
             'name': 'token',
             'token': ProjectFactory().token,
         }
     })
     data = Tasks.find_one(task_id)
     with LogCapture() as log_capture:
         token_service(data).should.be.none
         list(log_capture.actual())[0].should.contain('ERROR')
     Tasks.find({}).count().should.be.equal(0)
开发者ID:coviolations,项目名称:coviolations_web,代码行数:14,代码来源:test_token.py


示例18: _create_task

 def _create_task(self, **kwargs):
     defaults = {
         'project': self.project.name,
         'status': STATUS_SUCCESS,
     }
     defaults.update(kwargs)
     return Tasks.save(defaults)
开发者ID:michaeljoseph,项目名称:coviolations_web,代码行数:7,代码来源:test_forms.py


示例19: token_service

def token_service(data):
    """Find project by token and create task

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId or None -- pk of created task
    """
    try:
        project = Project.objects.get(token=data['service']['token'])

        assert data['project'] == project.name

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Token service fail: {}'.format(e))
开发者ID:coviolations,项目名称:coviolations_web,代码行数:17,代码来源:token.py


示例20: test_get_last_task

 def test_get_last_task(self):
     """Test get last task"""
     project = factories.ProjectFactory()
     task_id = Tasks.save({
         'project': project.name,
         'commit': {'branch': 'branch'},
     })
     project.get_last_task()['_id'].should.be.equal(task_id)
开发者ID:coviolations,项目名称:coviolations_web,代码行数:8,代码来源:test_models.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.shell函数代码示例发布时间:2022-05-27
下一篇:
Python models.Task类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap