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

Python json.dumps函数代码示例

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

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



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

示例1: test_user_story_action_bulk_update_order

def test_user_story_action_bulk_update_order(client, data):
    url = reverse('userstories-bulk-update-backlog-order')

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    post_data = json.dumps({
        "bulk_stories": [{"us_id": data.public_user_story.id, "order": 2}],
        "project_id": data.public_project.pk
    })
    results = helper_test_http_method(client, 'post', url, post_data, users)
    assert results == [401, 403, 403, 204, 204]

    post_data = json.dumps({
        "bulk_stories": [{"us_id": data.private_user_story1.id, "order": 2}],
        "project_id": data.private_project1.pk
    })
    results = helper_test_http_method(client, 'post', url, post_data, users)
    assert results == [401, 403, 403, 204, 204]

    post_data = json.dumps({
        "bulk_stories": [{"us_id": data.private_user_story2.id, "order": 2}],
        "project_id": data.private_project2.pk
    })
    results = helper_test_http_method(client, 'post', url, post_data, users)
    assert results == [401, 403, 403, 204, 204]
开发者ID:spetpet,项目名称:taiga-back,代码行数:31,代码来源:test_userstories_resources.py


示例2: test_not_send_notifications_on_unassigned_if_executer_and_unassigned_match

def test_not_send_notifications_on_unassigned_if_executer_and_unassigned_match(client, mail):
    project = f.ProjectFactory.create()
    role = f.RoleFactory.create(project=project, permissions=['modify_issue', 'view_issues', 'view_us', 'view_tasks', 'view_wiki_pages'])
    member1 = f.MembershipFactory.create(project=project, role=role)
    member2 = f.MembershipFactory.create(project=project, role=role)
    issue = f.IssueFactory.create(project=project,
                                  owner=member1.user,
                                  milestone=None,
                                  status=project.default_issue_status,
                                  severity=project.default_severity,
                                  priority=project.default_priority,
                                  type=project.default_issue_type)

    take_snapshot(issue, user=issue.owner)

    client.login(member1.user)
    url = reverse("issues-detail", args=[issue.pk])
    data = {
        "assigned_to": member1.user.id,
        "version": issue.version
    }
    response = client.json.patch(url, json.dumps(data))
    assert len(mail.outbox) == 0

    mail.outbox = []

    data = {
        "assigned_to": None,
        "version": issue.version + 1
    }
    response = client.json.patch(url, json.dumps(data))
    assert len(mail.outbox) == 0
开发者ID:tnir,项目名称:taiga-back,代码行数:32,代码来源:test_notifications.py


示例3: test_wiki_link_create

def test_wiki_link_create(client, data):
    url = reverse('wiki-links-list')

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    create_data = json.dumps({
        "title": "test",
        "href": "test",
        "project": data.public_project.pk,
    })
    results = helper_test_http_method(client, 'post', url, create_data, users, lambda: WikiLink.objects.all().delete())
    assert results == [401, 201, 201, 201, 201]

    create_data = json.dumps({
        "title": "test",
        "href": "test",
        "project": data.private_project1.pk,
    })
    results = helper_test_http_method(client, 'post', url, create_data, users, lambda: WikiLink.objects.all().delete())
    assert results == [401, 201, 201, 201, 201]

    create_data = json.dumps({
        "title": "test",
        "href": "test",
        "project": data.private_project2.pk,
    })
    results = helper_test_http_method(client, 'post', url, create_data, users, lambda: WikiLink.objects.all().delete())
    assert results == [401, 403, 403, 201, 201]
开发者ID:FlorianBezagu,项目名称:taiga-back,代码行数:34,代码来源:test_wiki_resources.py


示例4: test_api_update_order_in_bulk_invalid_user_story

def test_api_update_order_in_bulk_invalid_user_story(client):
    project = f.create_project()
    f.MembershipFactory.create(project=project, user=project.owner, is_admin=True)
    us1 = f.create_userstory(project=project)
    task1 = f.create_task(project=project, user_story=us1)
    task2 = f.create_task(project=project, user_story=us1)
    task3 = f.create_task(project=project)

    url1 = reverse("tasks-bulk-update-taskboard-order")
    url2 = reverse("tasks-bulk-update-us-order")

    data = {
        "project_id": project.id,
        "us_id": us1.id,
        "bulk_tasks": [{"task_id": task1.id, "order": 1},
                       {"task_id": task2.id, "order": 2},
                       {"task_id": task3.id, "order": 3}]
    }

    client.login(project.owner)

    response1 = client.json.post(url1, json.dumps(data))
    response2 = client.json.post(url2, json.dumps(data))

    assert response1.status_code == 400, response1.data
    assert response2.status_code == 400, response2.data
开发者ID:0-T-0,项目名称:taiga-back,代码行数:26,代码来源:test_tasks.py


示例5: test_api_update_orders_in_bulk

def test_api_update_orders_in_bulk(client):
    project = f.create_project()
    f.MembershipFactory.create(project=project, user=project.owner, is_admin=True)
    us1 = f.create_userstory(project=project)
    us2 = f.create_userstory(project=project)

    url1 = reverse("userstories-bulk-update-backlog-order")
    url2 = reverse("userstories-bulk-update-kanban-order")
    url3 = reverse("userstories-bulk-update-sprint-order")

    data = {
        "project_id": project.id,
        "bulk_stories": [{"us_id": us1.id, "order": 1},
                         {"us_id": us2.id, "order": 2}]
    }

    client.login(project.owner)

    response1 = client.json.post(url1, json.dumps(data))
    response2 = client.json.post(url2, json.dumps(data))
    response3 = client.json.post(url3, json.dumps(data))

    assert response1.status_code == 204, response1.data
    assert response2.status_code == 204, response2.data
    assert response3.status_code == 204, response3.data
开发者ID:OneOaaS,项目名称:taiga-back,代码行数:25,代码来源:test_userstories.py


示例6: test_user_story_patch_comment

def test_user_story_patch_comment(client, data):
    public_url = reverse('userstories-detail', kwargs={"pk": data.public_user_story.pk})
    private_url1 = reverse('userstories-detail', kwargs={"pk": data.private_user_story1.pk})
    private_url2 = reverse('userstories-detail', kwargs={"pk": data.private_user_story2.pk})
    blocked_url = reverse('userstories-detail', kwargs={"pk": data.blocked_user_story.pk})

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    with mock.patch.object(OCCResourceMixin, "_validate_and_update_version"):
        patch_data = json.dumps({"comment": "test comment", "version": data.public_user_story.version})
        results = helper_test_http_method(client, 'patch', public_url, patch_data, users)
        assert results == [401, 403, 403, 200, 200]

        patch_data = json.dumps({"comment": "test comment", "version": data.private_user_story1.version})
        results = helper_test_http_method(client, 'patch', private_url1, patch_data, users)
        assert results == [401, 403, 403, 200, 200]

        patch_data = json.dumps({"comment": "test comment", "version": data.private_user_story2.version})
        results = helper_test_http_method(client, 'patch', private_url2, patch_data, users)
        assert results == [401, 403, 403, 200, 200]

        patch_data = json.dumps({"comment": "test comment", "version": data.blocked_user_story.version})
        results = helper_test_http_method(client, 'patch', blocked_url, patch_data, users)
        assert results == [401, 403, 403, 451, 451]
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:30,代码来源:test_userstories_resources.py


示例7: test_webhook_update

def test_webhook_update(client, data):
    url1 = reverse('webhooks-detail', kwargs={"pk": data.webhook1.pk})
    url2 = reverse('webhooks-detail', kwargs={"pk": data.webhook2.pk})
    blocked_url = reverse('webhooks-detail', kwargs={"pk": data.blocked_webhook.pk})

    users = [
        None,
        data.registered_user,
        data.project_owner
    ]

    webhook_data = WebhookSerializer(data.webhook1).data
    webhook_data["key"] = "test"
    webhook_data = json.dumps(webhook_data)
    results = helper_test_http_method(client, 'put', url1, webhook_data, users)
    assert results == [401, 403, 200]

    webhook_data = WebhookSerializer(data.webhook2).data
    webhook_data["key"] = "test"
    webhook_data = json.dumps(webhook_data)
    results = helper_test_http_method(client, 'put', url2, webhook_data, users)
    assert results == [401, 403, 403]

    webhook_data = WebhookSerializer(data.blocked_webhook).data
    webhook_data["key"] = "test"
    webhook_data = json.dumps(webhook_data)
    results = helper_test_http_method(client, 'put', blocked_url, webhook_data, users)
    assert results == [401, 403, 451]
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:28,代码来源:test_webhooks_resources.py


示例8: test_valid_concurrent_save_for_issue_different_versions

def test_valid_concurrent_save_for_issue_different_versions(client):
    user = f.UserFactory.create()
    project = f.ProjectFactory.create(owner=user)
    f.MembershipFactory.create(project=project, user=user, is_owner=True)
    client.login(user)

    mock_path = "taiga.projects.issues.api.IssueViewSet.pre_conditions_on_save"
    with patch(mock_path):
        url = reverse("issues-list")
        data = {"subject": "test",
                "project": project.id,
                "status": f.IssueStatusFactory.create(project=project).id,
                "severity": f.SeverityFactory.create(project=project).id,
                "type": f.IssueTypeFactory.create(project=project).id,
                "priority": f.PriorityFactory.create(project=project).id}
        response = client.json.post(url, json.dumps(data))
        assert response.status_code == 201, response.content

        issue_id = response.data["id"]
        url = reverse("issues-detail", args=(issue_id,))
        data = {"version": 1, "subject": "test 1"}
        response = client.patch(url, json.dumps(data), content_type="application/json")
        assert response.status_code == 200

        data = {"version": 2, "subject": "test 2"}
        response = client.patch(url, json.dumps(data), content_type="application/json")
        assert response.status_code == 200
开发者ID:cubettech,项目名称:taiga-back,代码行数:27,代码来源:test_occ.py


示例9: test_userstory_custom_attribute_create

def test_userstory_custom_attribute_create(client, data):
    public_url = reverse('userstory-custom-attributes-list')
    private1_url = reverse('userstory-custom-attributes-list')
    private2_url = reverse('userstory-custom-attributes-list')

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    userstory_ca_data = {"name": "test-new", "project": data.public_project.id}
    userstory_ca_data = json.dumps(userstory_ca_data)
    results = helper_test_http_method(client, 'post', public_url, userstory_ca_data, users)
    assert results == [401, 403, 403, 403, 201]

    userstory_ca_data = {"name": "test-new", "project": data.private_project1.id}
    userstory_ca_data = json.dumps(userstory_ca_data)
    results = helper_test_http_method(client, 'post', private1_url, userstory_ca_data, users)
    assert results == [401, 403, 403, 403, 201]

    userstory_ca_data = {"name": "test-new", "project": data.private_project2.id}
    userstory_ca_data = json.dumps(userstory_ca_data)
    results = helper_test_http_method(client, 'post', private2_url, userstory_ca_data, users)
    assert results == [401, 403, 403, 403, 201]
开发者ID:cubettech,项目名称:taiga-back,代码行数:27,代码来源:test_userstories_custom_attributes_resource.py


示例10: test_task_custom_attributes_values_update

def test_task_custom_attributes_values_update(client, data):
    public_url = reverse('task-custom-attributes-values-detail', kwargs={"task_id": data.public_task.pk})
    private_url1 = reverse('task-custom-attributes-values-detail', kwargs={"task_id": data.private_task1.pk})
    private_url2 = reverse('task-custom-attributes-values-detail', kwargs={"task_id": data.private_task2.pk})

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    task_data = serializers.TaskCustomAttributesValuesSerializer(data.public_task_cav).data
    task_data["attributes_values"] = {str(data.public_task_ca.pk): "test"}
    task_data = json.dumps(task_data)
    results = helper_test_http_method(client, 'put', public_url, task_data, users)
    assert results == [401, 403, 403, 200, 200]

    task_data = serializers.TaskCustomAttributesValuesSerializer(data.private_task_cav1).data
    task_data["attributes_values"] = {str(data.private_task_ca1.pk): "test"}
    task_data = json.dumps(task_data)
    results = helper_test_http_method(client, 'put', private_url1, task_data, users)
    assert results == [401, 403, 403, 200, 200]

    task_data = serializers.TaskCustomAttributesValuesSerializer(data.private_task_cav2).data
    task_data["attributes_values"] = {str(data.private_task_ca2.pk): "test"}
    task_data = json.dumps(task_data)
    results = helper_test_http_method(client, 'put', private_url2, task_data, users)
    assert results == [401, 403, 403, 200, 200]
开发者ID:cubettech,项目名称:taiga-back,代码行数:30,代码来源:test_tasks_custom_attributes_resource.py


示例11: test_invalid_concurrent_save_for_us

def test_invalid_concurrent_save_for_us(client):
    user = f.UserFactory.create()
    project = f.ProjectFactory.create(owner=user)
    f.MembershipFactory.create(project=project, user=user, is_owner=True)
    f.UserStoryFactory.create(version=10, project=project)
    client.login(user)

    mock_path = "taiga.projects.userstories.api.UserStoryViewSet.pre_conditions_on_save"
    with patch(mock_path):
        url = reverse("userstories-list")
        data = {"subject": "test",
                "project": project.id,
                "status": f.UserStoryStatusFactory.create(project=project).id}
        response = client.json.post(url, json.dumps(data))
        assert response.status_code == 201

        userstory_id = response.data["id"]
        url = reverse("userstories-detail", args=(userstory_id,))
        data = {"version": 1, "subject": "test 1"}
        response = client.patch(url, json.dumps(data), content_type="application/json")
        assert response.status_code == 200

        data = {"version": 1, "subject": "test 2"}
        response = client.patch(url, json.dumps(data), content_type="application/json")
        assert response.status_code == 400
开发者ID:cubettech,项目名称:taiga-back,代码行数:25,代码来源:test_occ.py


示例12: test_modules_patch

def test_modules_patch(client, data):
    public_url = reverse('projects-modules', kwargs={"pk": data.public_project.pk})
    private_url1 = reverse('projects-modules', kwargs={"pk": data.private_project1.pk})
    private_url2 = reverse('projects-modules', kwargs={"pk": data.private_project2.pk})
    blocked_url = reverse('projects-modules', kwargs={"pk": data.blocked_project.pk})

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    with mock.patch.object(OCCResourceMixin, "_validate_and_update_version"):
        patch_data = json.dumps({"att": "test"})
        results = helper_test_http_method(client, 'patch', public_url, patch_data, users)
        assert results == [401, 403, 403, 403, 204]

        patch_data = json.dumps({"att": "test"})
        results = helper_test_http_method(client, 'patch', private_url1, patch_data, users)
        assert results == [401, 403, 403, 403, 204]

        patch_data = json.dumps({"att": "test"})
        results = helper_test_http_method(client, 'patch', private_url2, patch_data, users)
        assert results == [404, 404, 404, 403, 204]

        patch_data = json.dumps({"att": "test"})
        results = helper_test_http_method(client, 'patch', blocked_url, patch_data, users)
        assert results == [404, 404, 404, 403, 451]
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:30,代码来源:test_modules_resources.py


示例13: test_milestone_patch

def test_milestone_patch(client, data):
    public_url = reverse('milestones-detail', kwargs={"pk": data.public_milestone.pk})
    private_url1 = reverse('milestones-detail', kwargs={"pk": data.private_milestone1.pk})
    private_url2 = reverse('milestones-detail', kwargs={"pk": data.private_milestone2.pk})
    blocked_url = reverse('milestones-detail', kwargs={"pk": data.blocked_milestone.pk})

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    patch_data = json.dumps({"name": "test"})
    results = helper_test_http_method(client, 'patch', public_url, patch_data, users)
    assert results == [401, 403, 403, 200, 200]

    patch_data = json.dumps({"name": "test"})
    results = helper_test_http_method(client, 'patch', private_url1, patch_data, users)
    assert results == [401, 403, 403, 200, 200]

    patch_data = json.dumps({"name": "test"})
    results = helper_test_http_method(client, 'patch', private_url2, patch_data, users)
    assert results == [401, 403, 403, 200, 200]

    patch_data = json.dumps({"name": "test"})
    results = helper_test_http_method(client, 'patch', blocked_url, patch_data, users)
    assert results == [401, 403, 403, 451, 451]
开发者ID:SKOx0,项目名称:taiga-back,代码行数:29,代码来源:test_milestones_resources.py


示例14: test_issue_update

def test_issue_update(client, data):
    public_url = reverse('issues-detail', kwargs={"pk": data.public_issue.pk})
    private_url1 = reverse('issues-detail', kwargs={"pk": data.private_issue1.pk})
    private_url2 = reverse('issues-detail', kwargs={"pk": data.private_issue2.pk})

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    with mock.patch.object(OCCResourceMixin, "_validate_and_update_version"):
            issue_data = IssueSerializer(data.public_issue).data
            issue_data["subject"] = "test"
            issue_data = json.dumps(issue_data)
            results = helper_test_http_method(client, 'put', public_url, issue_data, users)
            assert results == [401, 403, 403, 200, 200]

            issue_data = IssueSerializer(data.private_issue1).data
            issue_data["subject"] = "test"
            issue_data = json.dumps(issue_data)
            results = helper_test_http_method(client, 'put', private_url1, issue_data, users)
            assert results == [401, 403, 403, 200, 200]

            issue_data = IssueSerializer(data.private_issue2).data
            issue_data["subject"] = "test"
            issue_data = json.dumps(issue_data)
            results = helper_test_http_method(client, 'put', private_url2, issue_data, users)
            assert results == [401, 403, 403, 200, 200]
开发者ID:lcyhff,项目名称:taiga-back,代码行数:31,代码来源:test_issues_resources.py


示例15: test_api_issue_add_new_tags_with_error

def test_api_issue_add_new_tags_with_error(client):
    project = f.ProjectFactory.create()
    issue = f.create_issue(project=project, status__project=project)
    f.MembershipFactory.create(project=project, user=issue.owner, is_admin=True)
    url = reverse("issues-detail", kwargs={"pk": issue.pk})
    data = {
        "tags": [],
        "version": issue.version
    }

    client.login(issue.owner)

    data["tags"] = [1]
    response = client.json.patch(url, json.dumps(data))
    assert response.status_code == 400, response.data
    assert "tags" in response.data

    data["tags"] = [["back"]]
    response = client.json.patch(url, json.dumps(data))
    assert response.status_code == 400, response.data
    assert "tags" in response.data

    data["tags"] = [["back", "#cccc"]]
    response = client.json.patch(url, json.dumps(data))
    assert response.status_code == 400, response.data
    assert "tags" in response.data

    data["tags"] = [[1, "#ccc"]]
    response = client.json.patch(url, json.dumps(data))
    assert response.status_code == 400, response.data
    assert "tags" in response.data
开发者ID:0-T-0,项目名称:taiga-back,代码行数:31,代码来源:test_issues_tags.py


示例16: test_userstory_custom_attribute_update

def test_userstory_custom_attribute_update(client, data):
    public_url = reverse('userstory-custom-attributes-detail', kwargs={"pk": data.public_userstory_ca.pk})
    private1_url = reverse('userstory-custom-attributes-detail', kwargs={"pk": data.private_userstory_ca1.pk})
    private2_url = reverse('userstory-custom-attributes-detail', kwargs={"pk": data.private_userstory_ca2.pk})

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    userstory_ca_data = serializers.UserStoryCustomAttributeSerializer(data.public_userstory_ca).data
    userstory_ca_data["name"] = "test"
    userstory_ca_data = json.dumps(userstory_ca_data)
    results = helper_test_http_method(client, 'put', public_url, userstory_ca_data, users)
    assert results == [401, 403, 403, 403, 200]

    userstory_ca_data = serializers.UserStoryCustomAttributeSerializer(data.private_userstory_ca1).data
    userstory_ca_data["name"] = "test"
    userstory_ca_data = json.dumps(userstory_ca_data)
    results = helper_test_http_method(client, 'put', private1_url, userstory_ca_data, users)
    assert results == [401, 403, 403, 403, 200]

    userstory_ca_data = serializers.UserStoryCustomAttributeSerializer(data.private_userstory_ca2).data
    userstory_ca_data["name"] = "test"
    userstory_ca_data = json.dumps(userstory_ca_data)
    results = helper_test_http_method(client, 'put', private2_url, userstory_ca_data, users)
    assert results == [401, 403, 403, 403, 200]
开发者ID:cubettech,项目名称:taiga-back,代码行数:30,代码来源:test_userstories_custom_attributes_resource.py


示例17: test_user_story_create

def test_user_story_create(client, data):
    url = reverse('userstories-list')

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    create_data = json.dumps({"subject": "test", "ref": 1, "project": data.public_project.pk})
    results = helper_test_http_method(client, 'post', url, create_data, users)
    assert results == [401, 403, 403, 201, 201]

    create_data = json.dumps({"subject": "test", "ref": 2, "project": data.private_project1.pk})
    results = helper_test_http_method(client, 'post', url, create_data, users)
    assert results == [401, 403, 403, 201, 201]

    create_data = json.dumps({"subject": "test", "ref": 3, "project": data.private_project2.pk})
    results = helper_test_http_method(client, 'post', url, create_data, users)
    assert results == [401, 403, 403, 201, 201]

    create_data = json.dumps({"subject": "test", "ref": 4, "project": data.blocked_project.pk})
    results = helper_test_http_method(client, 'post', url, create_data, users)
    assert results == [401, 403, 403, 451, 451]
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:26,代码来源:test_userstories_resources.py


示例18: test_userstory_custom_attribute_action_bulk_update_order

def test_userstory_custom_attribute_action_bulk_update_order(client, data):
    url = reverse('userstory-custom-attributes-bulk-update-order')

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    post_data = json.dumps({
        "bulk_userstory_custom_attributes": [(1,2)],
        "project": data.public_project.pk
    })
    results = helper_test_http_method(client, 'post', url, post_data, users)
    assert results == [401, 403, 403, 403, 204]

    post_data = json.dumps({
        "bulk_userstory_custom_attributes": [(1,2)],
        "project": data.private_project1.pk
    })
    results = helper_test_http_method(client, 'post', url, post_data, users)
    assert results == [401, 403, 403, 403, 204]

    post_data = json.dumps({
        "bulk_userstory_custom_attributes": [(1,2)],
        "project": data.private_project2.pk
    })
    results = helper_test_http_method(client, 'post', url, post_data, users)
    assert results == [401, 403, 403, 403, 204]
开发者ID:cubettech,项目名称:taiga-back,代码行数:31,代码来源:test_userstories_custom_attributes_resource.py


示例19: test_user_story_action_bulk_create

def test_user_story_action_bulk_create(client, data):
    url = reverse('userstories-bulk-create')

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    bulk_data = json.dumps({"bulk_stories": "test1\ntest2", "project_id": data.public_user_story.project.pk})
    results = helper_test_http_method(client, 'post', url, bulk_data, users)
    assert results == [401, 403, 403, 200, 200]

    bulk_data = json.dumps({"bulk_stories": "test1\ntest2", "project_id": data.private_user_story1.project.pk})
    results = helper_test_http_method(client, 'post', url, bulk_data, users)
    assert results == [401, 403, 403, 200, 200]

    bulk_data = json.dumps({"bulk_stories": "test1\ntest2", "project_id": data.private_user_story2.project.pk})
    results = helper_test_http_method(client, 'post', url, bulk_data, users)
    assert results == [401, 403, 403, 200, 200]

    bulk_data = json.dumps({"bulk_stories": "test1\ntest2", "project_id": data.blocked_user_story.project.pk})
    results = helper_test_http_method(client, 'post', url, bulk_data, users)
    assert results == [401, 403, 403, 451, 451]
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:26,代码来源:test_userstories_resources.py


示例20: test_userstory_custom_attributes_values_update

def test_userstory_custom_attributes_values_update(client, data):
    public_url = reverse('userstory-custom-attributes-values-detail', kwargs={
                                    "user_story_id": data.public_user_story.pk})
    private_url1 = reverse('userstory-custom-attributes-values-detail', kwargs={
                                    "user_story_id": data.private_user_story1.pk})
    private_url2 = reverse('userstory-custom-attributes-values-detail', kwargs={
                                    "user_story_id": data.private_user_story2.pk})

    users = [
        None,
        data.registered_user,
        data.project_member_without_perms,
        data.project_member_with_perms,
        data.project_owner
    ]

    user_story_data = serializers.UserStoryCustomAttributesValuesSerializer(data.public_user_story_cav).data
    user_story_data["attributes_values"] = {str(data.public_userstory_ca.pk): "test"}
    user_story_data = json.dumps(user_story_data)
    results = helper_test_http_method(client, 'put', public_url, user_story_data, users)
    assert results == [401, 403, 403, 200, 200]

    user_story_data = serializers.UserStoryCustomAttributesValuesSerializer(data.private_user_story_cav1).data
    user_story_data["attributes_values"] = {str(data.private_userstory_ca1.pk): "test"}
    user_story_data = json.dumps(user_story_data)
    results = helper_test_http_method(client, 'put', private_url1, user_story_data, users)
    assert results == [401, 403, 403, 200, 200]

    user_story_data = serializers.UserStoryCustomAttributesValuesSerializer(data.private_user_story_cav2).data
    user_story_data["attributes_values"] = {str(data.private_userstory_ca2.pk): "test"}
    user_story_data = json.dumps(user_story_data)
    results = helper_test_http_method(client, 'put', private_url2, user_story_data, users)
    assert results == [401, 403, 403, 200, 200]
开发者ID:cubettech,项目名称:taiga-back,代码行数:33,代码来源:test_userstories_custom_attributes_resource.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python json.loads函数代码示例发布时间:2022-05-27
下一篇:
Python dicts.dict_sum函数代码示例发布时间: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