コード例 #1
0
ファイル: test_column.py プロジェクト: wenbo1188/ozone
def test_update_essay_login(client, prepare, app, username, password):
    prepare.login(username, password)
    prepare.add_essay(num=1, title = "#test title old", content="test essay old")

    with app.app_context():
        db = get_db()
        res = db.cursor().execute("select timestamp from essay where title = ? and content = ?", 
            ["#test title old", "test essay old"]).fetchone()
        assert res is not None
    rv = client.get('/column/update', follow_redirects=True)
    assertTrue_status(rv, 404)

    rv = client.get('/column/update/1', follow_redirects=True)
    assertTrue_status(rv, 404)

    rv = client.get('/column/update/{}'.format(res["timestamp"]), follow_redirects=True)
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "#test title old")
    assertTrue_content(rv, "test essay old")

    rv = client.post('/column/update/{}'.format(res["timestamp"]), data={
        "title":"#test title new",
        "content":"test essay new"
    }, follow_redirects=True)
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "You have successfully update an essay")
    assertTrue_content(rv, "#test title new")
    assertTrue_content(rv, "test essay new")
コード例 #2
0
def test_update_message_login(client, prepare, app, username, password):
    prepare.login(username, password)
    prepare.add_message(num=1, content="test message old")

    with app.app_context():
        db = get_db()
        res = db.cursor().execute(
            "select timestamp from message where content = ?", [
                "test message old",
            ]).fetchone()
        assert res is not None
    rv = client.get('/message/update', follow_redirects=True)
    assertTrue_status(rv, 404)

    rv = client.get('/message/update/1', follow_redirects=True)
    assertTrue_status(rv, 404)

    rv = client.get('/message/update/{}'.format(res["timestamp"]),
                    follow_redirects=True)
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "test message old")

    rv = client.post('/message/update/{}'.format(res["timestamp"]),
                     data={"content": "test message new"},
                     follow_redirects=True)
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "You have successfully udpate a message")
    assertTrue_content(rv, "test message new")
コード例 #3
0
ファイル: test_column.py プロジェクト: wenbo1188/ozone
def test_add_essay_login(prepare, client, app, username, password):
    prepare.login(username, password)
    rv = client.get('/column/add')
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "提交")

    rv = client.post('/column/add', data={
        "title":"#test title",
        "content":"test essay"
    }, follow_redirects=True)
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "You have successfully add an essay")
    with app.app_context():
        db = get_db()
        assert db.cursor().execute('select * from essay where title = ? and content = ?', 
            ["#test title", "test essay"]).fetchone() is not None
コード例 #4
0
ファイル: test_column.py プロジェクト: wenbo1188/ozone
def test_add_essay_without_login(client, app):
    rv = client.get('/column/add', follow_redirects=True)
    assertTrue_status(rv, 200)
    assertFalse_content(rv, "提交")
    assertTrue_content(rv, "You need login to continue")

    rv = client.post('/column/add', data={
        "title":"#test title",
        "content":"test essay"
    }, follow_redirects=True)
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "You need login to continue")
    with app.app_context():
        db = get_db()
        assert db.cursor().execute("select * from essay where title = ? and content = ?", 
            ["#test title", "test essay"]).fetchone() is None
コード例 #5
0
def test_add_message_login(prepare, client, app, username, password):
    prepare.login(username, password)
    rv = client.get('/message/add')
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "提交")

    rv = client.post('/message/add',
                     data={"content": "test message"},
                     follow_redirects=True)
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "You have successfully leave a message")
    with app.app_context():
        db = get_db()
        assert db.cursor().execute('select * from message where content = ?', [
            "test message",
        ]).fetchone() is not None
コード例 #6
0
def test_add_message_without_login(client, app):
    rv = client.get('/message/add', follow_redirects=True)
    assertTrue_status(rv, 200)
    assertFalse_content(rv, "提交")
    assertTrue_content(rv, "You need login to continue")

    rv = client.post('/message/add',
                     data={"content": "test message"},
                     follow_redirects=True)
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "You need login to continue")
    with app.app_context():
        db = get_db()
        assert db.cursor().execute("select * from message where content = ?", [
            "test message",
        ]).fetchone() is None
コード例 #7
0
ファイル: test_column.py プロジェクト: wenbo1188/ozone
def test_delete_essay_login(client, prepare, app, username, password):
    prepare.login(username, password)
    prepare.add_essay()

    with app.app_context():
        db = get_db()
        res = db.cursor().execute("select timestamp from essay where title = ? and content = ?", 
            ["#test title", "test essay"]).fetchone()
        assert res is not None

    rv = client.get('/column/delete')
    assertTrue_status(rv, 404)
    
    rv = client.get('/column/delete/1')
    assertTrue_status(rv, 404)

    rv = client.get('/column/delete/{}'.format(res["timestamp"]), follow_redirects=True)
    assertTrue_status(rv, 200)
    assertTrue_content(rv, "You have successfully delete an essay")
    assertFalse_content(rv, "#test title")
    assertFalse_content(rv, "test essay")