當前位置: 首頁>>代碼示例>>Python>>正文


Python Tasks.save方法代碼示例

本文整理匯總了Python中tasks.models.Tasks.save方法的典型用法代碼示例。如果您正苦於以下問題:Python Tasks.save方法的具體用法?Python Tasks.save怎麽用?Python Tasks.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tasks.models.Tasks的用法示例。


在下文中一共展示了Tasks.save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_update_quality_game_with_new_violation

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 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,代碼行數:33,代碼來源:test_models.py

示例2: test_get_neutral_trend

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 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,代碼行數:11,代碼來源:test_models.py

示例3: test_get_success_percents

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 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,代碼行數:11,代碼來源:test_models.py

示例4: test_get_badge_with_filtering

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 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,代碼行數:11,代碼來源:test_views.py

示例5: _create_task

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 def _create_task(self, **kwargs):
     defaults = {
         'project': self.project.name,
         'status': STATUS_SUCCESS,
     }
     defaults.update(kwargs)
     return Tasks.save(defaults)
開發者ID:michaeljoseph,項目名稱:coviolations_web,代碼行數:9,代碼來源:test_forms.py

示例6: test_get_last_task

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 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,代碼行數:10,代碼來源:test_models.py

示例7: dummy_service

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
def dummy_service(data):
    """Create task from data dict

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId -- pk of created task
    """
    task_id = Tasks.save(data)
    return task_id
開發者ID:coviolations,項目名稱:coviolations_web,代碼行數:11,代碼來源:dummy.py

示例8: _create_task

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 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,代碼行數:12,代碼來源:test_travis_ci.py

示例9: test_attach_last_task

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 def test_attach_last_task(self):
     """Test attach last task"""
     project = factories.ProjectFactory(owner=self.user)
     task_id = Tasks.save({
         'project': project.name,
     })
     response = self.api_client.get(
         '{}{}/?with_last_task=true'.format(self.url, project.name),
     )
     self.deserialize(response)['last_task']['_id'].should.be\
         .equal(str(task_id))
開發者ID:michaeljoseph,項目名稱:coviolations_web,代碼行數:13,代碼來源:test_resources.py

示例10: test_success

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 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,代碼行數:13,代碼來源:test_token.py

示例11: create_task

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
def create_task(request):
    json_value = {}
    module_code = "04"
    module_status = ""
    if request.method == 'POST':
        if request.user.is_authenticated():
            if all(key in request.POST for key in ('name', 'description', 'priority', 'state', 'due_date')):
                name = request.POST['name']
                description = request.POST['description']
                priority = request.POST['priority']
                state = request.POST['state']
                due_date = request.POST['due_date']
                if priority and state and name and description and due_date:
                    if 1 <= int(priority) <= 5 and 1 <= int(state) <= 3:
                        task_object = Tasks()
                        task_object.name = name
                        task_object.description = description
                        task_object.priority = priority
                        task_object.state = state
                        task_object.due_date = due_date
                        task_object.user = request.user
                        try:
                            task_object.save()
                            module_status = "01"  # success
                        except ValidationError:
                            module_status = "00"  # post data; date field format not correct yyyy-mm-dd
                    else:
                        module_status = "00"  # post data error
                else:
                    module_status = "00"  # post data error
            else:
                module_status = "00"  # post data error
        else:
            module_status = "02"  # user not logged in
    else:
        module_status = "00"  # method not post
    json_value['status_code'] = module_code + module_status
    return_value = json.dumps(json_value)
    return HttpResponse(return_value)
開發者ID:anupsabraham,項目名稱:simple-to-do-list,代碼行數:41,代碼來源:views.py

示例12: test_fail_with_wrong_project

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
 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,代碼行數:16,代碼來源:test_token.py

示例13: token_service

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
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,代碼行數:19,代碼來源:token.py

示例14: travis_ci_service

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
def travis_ci_service(data):
    """Create tasks from data received from travis-c

    :param data: Data received from service
    :type data: dict
    :returns: bson.ObjectId or None -- pk of created task
    """
    try:
        assert Tasks.find({
            'service.name': 'travis_ci',
            'service.job_id': data['service']['job_id'],
        }).count() <= 1

        job = requests.get(
            'https://api.travis-ci.org/jobs/{}'.format(
                data['service']['job_id'],
            ),
        ).json()

        repo = requests.get(
            'https://api.travis-ci.org/repos/{}'.format(
                job['repository_id'],
            ),
        ).json()

        # TODO: add pull request support
        assert data['project'] == repo['slug']

        if data['service'].get('pull_request_id'):
            pull_request = data['service']['pull_request_id']
            if pull_request != 'false':
                data['pull_request_id'] = int(
                    data['service']['pull_request_id'],
                )

        return Tasks.save(data)
    except Exception as e:
        # remove task on error
        Tasks.remove(data['_id'])
        logger.exception('Travis-ci service fail: {}'.format(e))
開發者ID:coviolations,項目名稱:coviolations_web,代碼行數:42,代碼來源:travis_ci.py

示例15: coviolations_service

# 需要導入模塊: from tasks.models import Tasks [as 別名]
# 或者: from tasks.models.Tasks import save [as 別名]
def coviolations_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'])
        node_task = NodeTask.objects.get(
            id=data['service']['task_id'],
            project=project,
        )
        data['commit']['branch'] = node_task.branch

        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:michaeljoseph,項目名稱:coviolations_web,代碼行數:24,代碼來源:coviolations.py


注:本文中的tasks.models.Tasks.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。