import pytest
import os

from blog import create_app
from blog import db
from blog.post.models import Post


@pytest.fixture(scope='module')
def test_client():
    os.environ['FLASK_ENV'] = 'testing'
    app = create_app()
    db.init_app(app)
    testing_client = app.test_client()
    ctx = app.app_context()
    ctx.push()
    db.create_all()
    yield testing_client
    db.drop_all()
    ctx.pop()


def test_post(test_client):
    post = Post(pagetitle='ptitle', alias='posttest', content='tcontent', status=4)
    db.session.add(post)
    db.session.commit()
    rv = test_client.get('/posttest')
    assert rv.status == '200 OK'
    assert b'tcontent' in rv.data
    assert b'ptitle' in rv.data


def test_post_index(test_client):
    rv = test_client.get('/')
    assert rv.status == '200 OK'
    assert b'ptitle' in rv.data



@@ -712,114 +712,570 @@
 st_p
-ost_index(test_client):%0A    rv = test_client.get('/')%0A    assert rv.status == '200 OK'%0A    assert b'ptitle
+age(test_client):%0A    testpage = Post(pagetitle='pagetitle', alias='pagealias', content='pagecontent', status=4)%0A    db.session.add(testpage)%0A    db.session.commit()%0A    rv = test_client.get('/pagealias')%0A    assert rv.status == '200 OK'%0A    assert b'pagecontent' in rv.data%0A    assert b'pagetitle' in rv.data%0A%0A%0Adef test_post_index(test_client):%0A    rv = test_client.get('/')%0A    assert rv.status == '200 OK'%0A    assert b'ptitle' in rv.data%0A%0A%0Adef test_page_index(test_client):%0A    rv = test_client.get('/')%0A    assert rv.status == '200 OK'%0A    assert b'pagealias
 ' in

add page tests