コード例 #1
0
def test_wiki_attachment_update(client, data, data_wiki):
    public_url = reverse('wiki-attachments-detail', kwargs={"pk": data_wiki.public_wiki_attachment.pk})
    private_url1 = reverse('wiki-attachments-detail', kwargs={"pk": data_wiki.private_wiki1_attachment.pk})
    private_url2 = reverse('wiki-attachments-detail', kwargs={"pk": data_wiki.private_wiki2_attachment.pk})
    blocked_url = reverse('wiki-attachments-detail', kwargs={"pk": data_wiki.blocked_wiki_attachment.pk})

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

    attachment_data = AttachmentSerializer(data_wiki.public_wiki_attachment).data
    attachment_data["description"] = "test"
    attachment_data = json.dumps(attachment_data)

    results = helper_test_http_method(client, 'put', public_url, attachment_data, users)
    assert results == [405, 405, 405, 405, 405]
    # assert results == [401, 200, 200, 200, 200]

    results = helper_test_http_method(client, 'put', private_url1, attachment_data, users)
    assert results == [405, 405, 405, 405, 405]
    # assert results == [401, 200, 200, 200, 200]

    results = helper_test_http_method(client, 'put', private_url2, attachment_data, users)
    assert results == [405, 405, 405, 405, 405]
    # assert results == [401, 403, 403, 200, 200]

    results = helper_test_http_method(client, 'put', blocked_url, attachment_data, users)
    assert results == [405, 405, 405, 405, 405]
コード例 #2
0
def test_user_story_attachment_update(client, data, data_us):
    public_url = reverse("userstory-attachments-detail",
                         args=[data_us.public_user_story_attachment.pk])
    private_url1 = reverse("userstory-attachments-detail",
                           args=[data_us.private_user_story1_attachment.pk])
    private_url2 = reverse("userstory-attachments-detail",
                           args=[data_us.private_user_story2_attachment.pk])

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

    attachment_data = AttachmentSerializer(
        data_us.public_user_story_attachment).data
    attachment_data["description"] = "test"

    attachment_data = json.dumps(attachment_data)

    results = helper_test_http_method(client, "put", public_url,
                                      attachment_data, users)
    # assert results == [401, 403, 403, 400, 400]
    assert results == [405, 405, 405, 405, 405]

    results = helper_test_http_method(client, "put", private_url1,
                                      attachment_data, users)
    # assert results == [401, 403, 403, 400, 400]
    assert results == [405, 405, 405, 405, 405]

    results = helper_test_http_method(client, "put", private_url2,
                                      attachment_data, users)
    # assert results == [401, 403, 403, 400, 400]
    assert results == [405, 405, 405, 405, 405]