Merge pull request #1 from frankenmichl/add_tests

Add tests
pull/3/head
Johannes Thumshirn 4 years ago committed by GitHub
commit d8167fbd72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,23 @@
PYTHON=python3
PYCODESTYLE=pycodestyle
.DEFAULT_GOAL = help
help:
@echo "The following targets are supported:"
@echo " setup install required packages"
@echo " test run the tests"
setup:
pip install -r requirements.txt
test:
${PYCODESTYLE} *.py
${PYTHON} -m pytest
clean:
@echo "cleaning"
.PHONY: setup test clean help

@ -9,26 +9,31 @@ app.config['FLATPAGES_EXTENSION'] = '.md'
pages = FlatPages(app) pages = FlatPages(app)
@app.route('/<path:path>.html') @app.route('/<path:path>.html')
def page(path): def page(path):
page = pages.get_or_404(path) page = pages.get_or_404(path)
return render_template('page.html', page=page) return render_template('page.html', page=page)
@app.route('/verein.html') @app.route('/verein.html')
def verein(): def verein():
return render_template('verein.html') return render_template('verein.html')
@app.route('/impressum.html') @app.route('/impressum.html')
def impressum(): def impressum():
return render_template('impressum.html') return render_template('impressum.html')
@app.route('/') @app.route('/')
@app.route('/index.html') @app.route('/index.html')
def index(): def index():
posts = [p for p in pages if "date" in p.meta] posts = [p for p in pages if "date" in p.meta]
sorted_pages = sorted(posts, reverse=True, key=lambda page: sorted_pages = sorted(posts, reverse=True, key=lambda page
datetime.strptime(page.meta["date"], "%d %b %y")) datetime.strptime(page.meta["date"], "%d %b %y"))
return render_template('index.html', pages=sorted_pages) return render_template('index.html', pages=sorted_pages)
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0') app.run(host='0.0.0.0')

@ -1,2 +1,8 @@
flask flask
flask_flatpages flask_flatpages
pytest
pytest-cov
requests
pycodestyle
codecov

Loading…
Cancel
Save