示例#1
0
def test_edit_post_wrong_user(client, post, user_not_in_blog_with_token):
    rv = client.put(
        "/posts/" + post.url + "/",
        json={"title": "new title"},
        headers={"Authorization": user_not_in_blog_with_token[1].token},
    )
    assert rv.json["success"] == 0
    assert rv.json["error"]["code"] == 3

    assert Post.get().title == post.title, "Post title changed"
    assert Post.get().title != "new title"
示例#2
0
def test_edit_post_with_cut(client, post, user_token):
    rv = client.put(
        "/posts/" + post.url + "/",
        json={"text": '<p>Some text</p><cut name="it\'s cut"></cut><p>More text</p>"'},
        headers={"Authorization": user_token[1].token},
    )
    assert rv.json["success"] == 1

    assert Post.get().cut_text == "<p>Some text</p>"
    assert Post.get().cut_name == "it's cut"
    assert (
        Post.get().text
        == '<p>Some text</p><cut name="it\'s cut"></cut><p>More text</p>"'
    )
示例#3
0
def test_edit_post(client, post, user_token):
    rv = client.put(
        "/posts/" + post.url + "/",
        json={"title": "new title"},
        headers={"Authorization": user_token[1].token},
    )
    assert rv.json["success"] == 1

    assert Post.get().title == "new title", "Post title not chaged"
示例#4
0
def test_create_post(client, user_token):
    rv = client.post(
        "/posts/",
        headers={"Authorization": user_token[1].token},
        json={"url": "sample-url"},
    )
    assert rv.json["success"] == 1
    assert "post" in rv.json, "No post in response"

    post = Post.get()
    assert post.creator == user_token[0], "Wrong creator"
    assert post.id == rv.json["post"]["id"]