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


Python services.take_snapshot函数代码示例

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


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

示例1: snapshot_issues_in_bulk

def snapshot_issues_in_bulk(bulk_data, user):
    for issue_data in bulk_data:
        try:
            issue = models.Issue.objects.get(pk=issue_data['issue_id'])
            take_snapshot(issue, user=user)
        except models.Issue.DoesNotExist:
            pass
开发者ID:taigaio,项目名称:taiga-back,代码行数:7,代码来源:services.py

示例2: snapshot_tasks_in_bulk

def snapshot_tasks_in_bulk(bulk_data, user):
    for task_data in bulk_data:
        try:
            task = models.Task.objects.get(pk=task_data['task_id'])
            take_snapshot(task, user=user)
        except models.Task.DoesNotExist:
            pass
开发者ID:aminadha,项目名称:taiga-back,代码行数:7,代码来源:services.py

示例3: snapshot_userstories_in_bulk

def snapshot_userstories_in_bulk(bulk_data, user):
    for us_data in bulk_data:
        try:
            us = models.UserStory.objects.get(pk=us_data['us_id'])
            take_snapshot(us, user=user)
        except models.UserStory.DoesNotExist:
            pass
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:7,代码来源:services.py

示例4: test_issues_event_bad_comment

def test_issues_event_bad_comment(client):
    issue = f.IssueFactory.create(external_reference=["gitlab", "10"])
    take_snapshot(issue, user=issue.owner)

    payload = {
        "user": {
            "username": "test"
        },
        "issue": {
            "iid": "10",
            "title": "test-title",
        },
        "object_attributes": {
            "noteable_type": "Issue",
        },
        "repository": {
            "homepage": "test",
        },
    }
    ev_hook = event_hooks.IssueCommentEventHook(issue.project, payload)

    mail.outbox = []

    with pytest.raises(ActionSyntaxException) as excinfo:
        ev_hook.process_event()

    assert str(excinfo.value) == "Invalid issue comment information"

    assert Issue.objects.count() == 1
    assert len(mail.outbox) == 0
开发者ID:SKOx0,项目名称:taiga-back,代码行数:30,代码来源:test_hooks_gitlab.py

示例5: test_issues_event_bad_comment

def test_issues_event_bad_comment(client):
    issue = f.IssueFactory.create(external_reference=["bitbucket", "10"])
    take_snapshot(issue, user=issue.owner)

    payload = {
        "actor": {
            "user": {
                "uuid": "{ce1054cd-3f43-49dc-8aea-d3085ee7ec9b}",
                "username": "test-user",
                "links": {"html": {"href": "http://bitbucket.com/test-user"}}
            }
        },
        "issue": {
            "id": "10",
            "title": "test-title",
            "links": {"html": {"href": "http://bitbucket.com/site/master/issue/10"}},
            "content": {"raw": "test-content"}
        },
        "comment": {
        },
        "repository": {
            "links": {"html": {"href": "http://bitbucket.com/test-user/test-project"}}
        }
    }
    ev_hook = event_hooks.IssueCommentEventHook(issue.project, payload)

    mail.outbox = []

    with pytest.raises(ActionSyntaxException) as excinfo:
        ev_hook.process_event()

    assert str(excinfo.value) == "Invalid issue comment information"

    assert Issue.objects.count() == 1
    assert len(mail.outbox) == 0
开发者ID:74Labs,项目名称:taiga-back,代码行数:35,代码来源:test_hooks_bitbucket.py

示例6: test_create_task_timeline

def test_create_task_timeline():
    task = factories.TaskFactory.create(subject="test task timeline")
    history_services.take_snapshot(task, user=task.owner)
    project_timeline = service.get_project_timeline(task.project)
    assert project_timeline[0].event_type == "tasks.task.create"
    assert project_timeline[0].data["task"]["subject"] == "test task timeline"
    assert project_timeline[0].data["user"]["id"] == task.owner.id
开发者ID:cubettech,项目名称:taiga-back,代码行数:7,代码来源:test_timeline.py

示例7: test_assigned_to_user_story_timeline

def test_assigned_to_user_story_timeline():
    membership = factories.MembershipFactory.create()
    user_story = factories.UserStoryFactory.create(subject="test us timeline", assigned_to=membership.user, project=membership.project)
    history_services.take_snapshot(user_story, user=user_story.owner)
    user_timeline = service.get_profile_timeline(user_story.assigned_to)
    assert user_timeline[0].event_type == "userstories.userstory.create"
    assert user_timeline[0].data["userstory"]["subject"] == "test us timeline"
开发者ID:cubettech,项目名称:taiga-back,代码行数:7,代码来源:test_timeline.py

示例8: create_us

    def create_us(self, project, milestone=None, computable_project_roles=list(Role.objects.all())):
        us = UserStory.objects.create(subject=self.sd.choice(SUBJECT_CHOICES),
                                      project=project,
                                      owner=self.sd.db_object_from_queryset(
                                              project.memberships.filter(user__isnull=False)).user,
                                      description=self.sd.paragraph(),
                                      milestone=milestone,
                                      status=self.sd.db_object_from_queryset(project.us_statuses.filter(
                                                                             is_closed=False)),
                                      tags=self.sd.words(1, 3).split(" "))

        for role_points in us.role_points.filter(role__in=computable_project_roles):
            if milestone:
                role_points.points = self.sd.db_object_from_queryset(
                                us.project.points.exclude(value=None))
            else:
                role_points.points = self.sd.db_object_from_queryset(
                                              us.project.points.all())

            role_points.save()

        for i in range(self.sd.int(*NUM_ATTACHMENTS)):
            attachment = self.create_attachment(us, i+1)

        if self.sd.choice([True, True, False, True, True]):
            us.assigned_to = self.sd.db_object_from_queryset(project.memberships.filter(user__isnull=False)).user
            us.save()

        take_snapshot(us,
                      comment=self.sd.paragraph(),
                      user=us.owner)

        return us
开发者ID:6ft,项目名称:taiga-back,代码行数:33,代码来源:sample_data.py

示例9: create_bug

    def create_bug(self, project):
        bug = Issue.objects.create(project=project,
                                   subject=self.sd.choice(SUBJECT_CHOICES),
                                   description=self.sd.paragraph(),
                                   owner=self.sd.db_object_from_queryset(
                                            project.memberships.filter(user__isnull=False)).user,
                                   severity=self.sd.db_object_from_queryset(Severity.objects.filter(
                                                                                    project=project)),
                                   status=self.sd.db_object_from_queryset(IssueStatus.objects.filter(
                                                                                     project=project)),
                                   priority=self.sd.db_object_from_queryset(Priority.objects.filter(
                                                                                    project=project)),
                                   type=self.sd.db_object_from_queryset(IssueType.objects.filter(
                                                                                 project=project)),
                                   tags=self.sd.words(1, 10).split(" "))

        for i in range(self.sd.int(*NUM_ATTACHMENTS)):
            attachment = self.create_attachment(bug, i+1)

        if bug.status.order != 1:
            bug.assigned_to = self.sd.db_object_from_queryset(project.memberships.filter(
                                                                      user__isnull=False)).user
            bug.save()

        take_snapshot(bug,
                      comment=self.sd.paragraph(),
                      user=bug.owner)

        return bug
开发者ID:6ft,项目名称:taiga-back,代码行数:29,代码来源:sample_data.py

示例10: create_task

    def create_task(self, project, milestone, us, min_date, max_date, closed=False):
        task = Task(subject=self.sd.choice(SUBJECT_CHOICES),
                    description=self.sd.paragraph(),
                    project=project,
                    owner=self.sd.db_object_from_queryset(project.memberships.filter(user__isnull=False)).user,
                    milestone=milestone,
                    user_story=us,
                    finished_date=None,
                    assigned_to = self.sd.db_object_from_queryset(
                    project.memberships.filter(user__isnull=False)).user,
                    tags=self.sd.words(1, 10).split(" "))

        if closed:
            task.status = project.task_statuses.get(order=4)
        else:
            task.status = self.sd.db_object_from_queryset(project.task_statuses.all())

        if task.status.is_closed:
            task.finished_date = self.sd.datetime_between(min_date, max_date)

        task.save()

        for i in range(self.sd.int(*NUM_ATTACHMENTS)):
            attachment = self.create_attachment(task, i+1)

        take_snapshot(task,
                      comment=self.sd.paragraph(),
                      user=task.owner)

        return task
开发者ID:6ft,项目名称:taiga-back,代码行数:30,代码来源:sample_data.py

示例11: test_webhooks_when_update_epic_related_userstory

def test_webhooks_when_update_epic_related_userstory(settings):
    settings.WEBHOOKS_ENABLED = True
    project = f.ProjectFactory()
    f.WebhookFactory.create(project=project)
    f.WebhookFactory.create(project=project)

    epic = f.EpicFactory.create(project=project)
    obj = f.RelatedUserStory.create(epic=epic, order=33)

    with patch('taiga.webhooks.tasks._send_request') as send_request_mock:
        services.take_snapshot(obj, user=epic.owner)
        assert send_request_mock.call_count == 2

    obj.order = 66
    obj.save()

    with patch('taiga.webhooks.tasks._send_request') as send_request_mock:
        services.take_snapshot(obj, user=epic.owner)
        assert send_request_mock.call_count == 2

        (webhook_id, url, key, data) = send_request_mock.call_args[0]
        assert data["action"] == "change"
        assert data["type"] == "relateduserstory"
        assert data["by"]["id"] == epic.owner.id
        assert "date" in data
        assert data["data"]["id"] == obj.id
        assert data["data"]["order"] == obj.order
        assert data["change"]["diff"]["order"]["to"] == 66
        assert data["change"]["diff"]["order"]["from"] == 33
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:29,代码来源:test_webhooks_epics.py

示例12: _process_opened

    def _process_opened(self, number, subject, github_url, user, github_user_name, github_user_url, project_url, description):
        issue = Issue.objects.create(
            project=self.project,
            subject=subject,
            description=description,
            status=self.project.default_issue_status,
            type=self.project.default_issue_type,
            severity=self.project.default_severity,
            priority=self.project.default_priority,
            external_reference=['github', github_url],
            owner=user
        )
        take_snapshot(issue, user=user)

        if number and subject and github_user_name and github_user_url:
            comment = _("Issue created by [@{github_user_name}]({github_user_url} "
                        "\"See @{github_user_name}'s GitHub profile\") "
                        "from GitHub.\nOrigin GitHub issue: [gh#{number} - {subject}]({github_url} "
                        "\"Go to 'gh#{number} - {subject}'\"):\n\n"
                        "{description}").format(github_user_name=github_user_name,
                                                github_user_url=github_user_url,
                                                number=number,
                                                subject=subject,
                                                github_url=github_url,
                                                description=description)
        else:
            comment = _("Issue created from GitHub.")

        snapshot = take_snapshot(issue, comment=comment, user=user)
        send_notifications(issue, history=snapshot)
开发者ID:alvarollmenezes,项目名称:taiga-back,代码行数:30,代码来源:event_hooks.py

示例13: process_event

    def process_event(self):
        if self.ignore():
            return

        data = self.get_data()

        if not all([data['subject'], data['url']]):
            raise ActionSyntaxException(_("Invalid issue information"))

        user = self.get_user(data['user_id'], self.platform_slug)

        issue = Issue.objects.create(
            project=self.project,
            subject=data['subject'],
            description=data['description'],
            status=self.project.default_issue_status,
            type=self.project.default_issue_type,
            severity=self.project.default_severity,
            priority=self.project.default_priority,
            external_reference=[self.platform_slug, data['url']],
            owner=user
        )
        take_snapshot(issue, user=user)

        comment = self.generate_new_issue_comment(**data)

        snapshot = take_snapshot(issue, comment=comment, user=user)
        send_notifications(issue, history=snapshot)
开发者ID:0-T-0,项目名称:taiga-back,代码行数:28,代码来源:event_hooks.py

示例14: test_create_user_story_timeline

def test_create_user_story_timeline():
    user_story = factories.UserStoryFactory.create(subject="test us timeline")
    history_services.take_snapshot(user_story, user=user_story.owner)
    project_timeline = service.get_project_timeline(user_story.project)
    assert project_timeline[0].event_type == "userstories.userstory.create"
    assert project_timeline[0].data["userstory"]["subject"] == "test us timeline"
    assert project_timeline[0].data["user"]["id"] == user_story.owner.id
开发者ID:cubettech,项目名称:taiga-back,代码行数:7,代码来源:test_timeline.py

示例15: test_send_request_one_webhook_signal

def test_send_request_one_webhook_signal(settings):
    settings.WEBHOOKS_ENABLED = True
    project = f.ProjectFactory()
    f.WebhookFactory.create(project=project)

    objects = [
        f.IssueFactory.create(project=project),
        f.TaskFactory.create(project=project),
        f.UserStoryFactory.create(project=project),
        f.WikiPageFactory.create(project=project)
    ]

    response = Mock(status_code=200, headers={}, text="ok")
    response.elapsed.total_seconds.return_value = 100

    for obj in objects:
        with patch("taiga.webhooks.tasks.requests.Session.send", return_value=response) as session_send_mock, \
         patch("taiga.base.utils.urls.validate_private_url", return_value=True):
            services.take_snapshot(obj, user=obj.owner, comment="test")
            assert session_send_mock.call_count == 1

    for obj in objects:
        with patch("taiga.webhooks.tasks.requests.Session.send", return_value=response) as session_send_mock, \
         patch("taiga.base.utils.urls.validate_private_url", return_value=True):
            services.take_snapshot(obj, user=obj.owner, comment="test", delete=True)
            assert session_send_mock.call_count == 1
开发者ID:taigaio,项目名称:taiga-back,代码行数:26,代码来源:test_webhooks_signals.py


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