tests added
This commit is contained in:
@@ -1 +1,3 @@
|
||||
title: Stuff Sample
|
||||
title: IndexPage
|
||||
|
||||
asdfasdfasdf
|
||||
@@ -6,11 +6,11 @@ import flatpages_index
|
||||
def create_bp(app):
|
||||
|
||||
flatpages = FlatPagesIndex(app)
|
||||
flatpages_index.Links.endpoint="stuff.page"
|
||||
flatpages_index.Links.endpoint="pages.page"
|
||||
flatpages_index.Links.url=(lambda s,x: url_for(s.endpoint, name=x))
|
||||
#flatpages_index.Links.image_url=(lambda s,x: url_for('stuff.page', name=x))
|
||||
flatpages_index.Links.file_url=(lambda s,x: url_for('stuff.page', name=x))
|
||||
flatpages_index.Links.thumb_url=(lambda s,x: url_for('stuff.thumb', size=128,name=x))
|
||||
flatpages_index.Links.file_url=(lambda s,x: url_for('pages.page', name=x))
|
||||
flatpages_index.Links.thumb_url=(lambda s,x: url_for('pages.thumb', size=128,name=x))
|
||||
|
||||
flatpages.get('index')
|
||||
app.logger.debug('flatpages loaded %d pages' % len(flatpages._pages))
|
||||
@@ -28,7 +28,7 @@ def create_bp(app):
|
||||
|
||||
if page:
|
||||
page["has_img"]=True
|
||||
page.links.endpoint='stuff.page'
|
||||
page.links.endpoint='pages.page'
|
||||
return render_template(page["template"], post=page,
|
||||
pth=page["dirpath"])
|
||||
|
||||
@@ -45,7 +45,7 @@ def create_bp(app):
|
||||
page = flatpages.get(name)
|
||||
if not page is None:
|
||||
page["has_img"]=False
|
||||
page.links.endpoint='stuff.pagejson'
|
||||
page.links.endpoint='pages.pagejson'
|
||||
# page.links.file_url=lambda n: url_for('intern.post', name=n)
|
||||
return jsonify(page=dict(page))
|
||||
|
||||
|
||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
32
tests/test_basic.py
Normal file
32
tests/test_basic.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from .test_fixtures import client,app
|
||||
import json
|
||||
import logging
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def index_html(client):
|
||||
resp = client.get('/index/')
|
||||
data= resp.get_data(as_text=True)
|
||||
return data
|
||||
|
||||
def test_index(app,client):
|
||||
# Try to get "index"
|
||||
resp = client.get('index.json')
|
||||
data = json.loads(resp.get_data(as_text=True))
|
||||
assert resp.status_code == 200
|
||||
assert data['page']['title'] == "IndexPage"
|
||||
|
||||
|
||||
def test_index_html(app,client):
|
||||
# Try to get "index"
|
||||
resp = client.get('/index/')
|
||||
#data= resp.get_data(as_text=True)
|
||||
#app.logger.debug()
|
||||
|
||||
assert resp.status_code == 200
|
||||
|
||||
def test_links_in_index(index_html):
|
||||
assert 'href="/topic1/"' in index_html
|
||||
|
||||
def test_text_in_index(index_html):
|
||||
assert 'asdfasdfasdf' in index_html
|
||||
10
tests/test_fixtures.py
Normal file
10
tests/test_fixtures.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import os
|
||||
import pytest
|
||||
from flaskpages import create_app
|
||||
|
||||
@pytest.fixture
|
||||
def app():
|
||||
return create_app()
|
||||
@pytest.fixture
|
||||
def client(app):
|
||||
return app.test_client()
|
||||
Reference in New Issue
Block a user