mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 14:59:43 +00:00
parent
9b1a739347
commit
4db11b91b7
8 changed files with 137 additions and 31 deletions
23
.drone.yml
23
.drone.yml
|
|
@ -9,7 +9,7 @@ services:
|
||||||
COUCHDB_PASSWORD: password
|
COUCHDB_PASSWORD: password
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: test
|
- name: tests
|
||||||
image: python:3.6
|
image: python:3.6
|
||||||
environment:
|
environment:
|
||||||
COUCH_URL: 'http://couchdb:5984'
|
COUCH_URL: 'http://couchdb:5984'
|
||||||
|
|
@ -27,7 +27,7 @@ steps:
|
||||||
- pip install codecov
|
- pip install codecov
|
||||||
- codecov
|
- codecov
|
||||||
# Perform linting checks
|
# Perform linting checks
|
||||||
- black --check src tests
|
- black --check src tests setup.py
|
||||||
- flake8
|
- flake8
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
@ -35,6 +35,23 @@ kind: pipeline
|
||||||
name: publish
|
name: publish
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: version-dev
|
||||||
|
image: python:3.6
|
||||||
|
commands:
|
||||||
|
- sed -i "s/.dev/.dev${DRONE_BUILD_NUMBER}/" src/humulus/_version.py
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
exclude:
|
||||||
|
- tag
|
||||||
|
|
||||||
|
- name: version-release
|
||||||
|
image: python:3.6
|
||||||
|
commands:
|
||||||
|
- sed -i "s/.dev//" src/humulus/_version.py
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
|
||||||
- name: docker-dev
|
- name: docker-dev
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
|
|
@ -44,7 +61,7 @@ steps:
|
||||||
from_secret: DOCKER_PASSWORD
|
from_secret: DOCKER_PASSWORD
|
||||||
repo: shouptech/humulus
|
repo: shouptech/humulus
|
||||||
tags:
|
tags:
|
||||||
- ${DRONE_COMMIT_SHA}
|
- ${DRONE_BUILD_NUMBER}
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
|
|
|
||||||
44
setup.py
44
setup.py
|
|
@ -17,36 +17,38 @@ from os import path
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
this_directory = path.abspath(path.dirname(__file__))
|
this_directory = path.abspath(path.dirname(__file__))
|
||||||
with open(path.join(this_directory, 'README.rst'), encoding='utf-8') as f:
|
# Get contents of README
|
||||||
|
with open(path.join(this_directory, "README.rst"), encoding="utf-8") as f:
|
||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
||||||
|
# Get current version number
|
||||||
|
version = {}
|
||||||
|
with open(path.join(this_directory, "src/humulus/_version.py")) as f:
|
||||||
|
exec(f.read(), version)
|
||||||
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'Flask==1.0.3',
|
"Flask==1.0.3",
|
||||||
'Flask-WTF==0.14.2',
|
"Flask-WTF==0.14.2",
|
||||||
'simplejson==3.16.0',
|
"simplejson==3.16.0",
|
||||||
'python-slugify==3.0.2',
|
"python-slugify==3.0.2",
|
||||||
'cloudant==2.12.0',
|
"cloudant==2.12.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='humulus',
|
name="humulus",
|
||||||
version='0.0.1',
|
version=version["__version__"],
|
||||||
url='https://github.com/shouptech/humulus',
|
url="https://github.com/shouptech/humulus",
|
||||||
author='Mike Shoup',
|
author="Mike Shoup",
|
||||||
author_email='mike@shoup.io',
|
author_email="mike@shoup.io",
|
||||||
description='Humulus is a beer recipe builder.',
|
description="Humulus is a beer recipe builder.",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type='text/x-rst',
|
long_description_content_type="text/x-rst",
|
||||||
package_dir={'': 'src'},
|
package_dir={"": "src"},
|
||||||
packages=find_packages(where='src'),
|
packages=find_packages(where="src"),
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=install_requires,
|
install_requires=install_requires,
|
||||||
setup_requires=install_requires + [
|
setup_requires=install_requires + ["pytest-runner"],
|
||||||
'pytest-runner',
|
tests_require=["pytest"],
|
||||||
],
|
|
||||||
tests_require=[
|
|
||||||
'pytest',
|
|
||||||
],
|
|
||||||
classifiers=[],
|
classifiers=[],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
17
src/humulus/_version.py
Normal file
17
src/humulus/_version.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Copyright 2019 Mike Shoup
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# The 'dev' portion of this variable will get updated during Drone CI builds
|
||||||
|
# with a build number for all non-tagged builds.
|
||||||
|
__version__ = "0.0.1.dev"
|
||||||
|
|
@ -28,6 +28,11 @@ def create_app(test_config=None):
|
||||||
# Load config from configuration provided via ENV
|
# Load config from configuration provided via ENV
|
||||||
app.config.from_envvar("HUMULUS_SETTINGS")
|
app.config.from_envvar("HUMULUS_SETTINGS")
|
||||||
|
|
||||||
|
# Load current version of humulus
|
||||||
|
from . import _version
|
||||||
|
|
||||||
|
app.config["version"] = _version.__version__
|
||||||
|
|
||||||
from . import couch
|
from . import couch
|
||||||
|
|
||||||
couch.init_app(app)
|
couch.init_app(app)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,15 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from flask import Blueprint, redirect, url_for, request, jsonify
|
from flask import (
|
||||||
|
current_app,
|
||||||
|
Blueprint,
|
||||||
|
redirect,
|
||||||
|
url_for,
|
||||||
|
request,
|
||||||
|
jsonify,
|
||||||
|
render_template,
|
||||||
|
)
|
||||||
|
|
||||||
from humulus.couch import get_db
|
from humulus.couch import get_db
|
||||||
|
|
||||||
|
|
@ -27,11 +35,20 @@ def index():
|
||||||
return redirect(url_for("recipes.index"))
|
return redirect(url_for("recipes.index"))
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/about")
|
||||||
|
def about():
|
||||||
|
"""Render the about page."""
|
||||||
|
return render_template("about.html")
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/status")
|
@bp.route("/status")
|
||||||
def status():
|
def status():
|
||||||
|
status = {"version": current_app.config["version"]}
|
||||||
if request.args.get("couch", default=False):
|
if request.args.get("couch", default=False):
|
||||||
if get_db().exists():
|
if get_db().exists():
|
||||||
return jsonify({"ping": "ok", "couch": "ok"}), 200
|
status["couch"] = "ok"
|
||||||
|
return jsonify(status), 200
|
||||||
else:
|
else:
|
||||||
return jsonify({"ping": "ok", "couch": "not_exist"}), 500
|
status["couch"] = "not_exist"
|
||||||
return jsonify({"ping": "ok"}), 200
|
return jsonify(status), 500
|
||||||
|
return jsonify(status), 200
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto">
|
||||||
|
<li class="nav-item {% if request.url_rule.endpoint == 'home.about' %}active{% endif %}">
|
||||||
|
<a class="nav-link" href="{{ url_for('home.about') }}">About</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
{% if session.logged_in %}
|
{% if session.logged_in %}
|
||||||
<a class="nav-link" href="{{ url_for('auth.logout') }}">Logout</a>
|
<a class="nav-link" href="{{ url_for('auth.logout') }}">Logout</a>
|
||||||
|
|
|
||||||
31
src/humulus/templates/about.html
Normal file
31
src/humulus/templates/about.html
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
{#-
|
||||||
|
Copyright 2019 Mike Shoup
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-#}
|
||||||
|
{% extends '_base.html' %}
|
||||||
|
{% block title %}About Humulus{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div><h1>About Humulus</h1></div>
|
||||||
|
<div class="row"><div class="col">
|
||||||
|
Humulus version: {{ config.version }}
|
||||||
|
</div></div>
|
||||||
|
<div class="row"><div class="col">
|
||||||
|
<a href="https://github.com/shouptech/humulus/">Humulus</a> is an open source application for building beer recipes.
|
||||||
|
</div></div>
|
||||||
|
<div class="row"><div class="col">
|
||||||
|
Humulus is licensed under the
|
||||||
|
<a href="https://github.com/shouptech/humulus/blob/master/LICENSE">Apache v2.0 License</a>.
|
||||||
|
</div></div>
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -12,12 +12,20 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from humulus import _version
|
||||||
|
|
||||||
|
|
||||||
def test_home(client):
|
def test_home(client):
|
||||||
response = client.get("/")
|
response = client.get("/")
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
|
|
||||||
|
|
||||||
|
def test_about(client):
|
||||||
|
response = client.get("/about")
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert _version.__version__ in str(response.data)
|
||||||
|
|
||||||
|
|
||||||
def test_status(client, monkeypatch):
|
def test_status(client, monkeypatch):
|
||||||
class MockDBTrue:
|
class MockDBTrue:
|
||||||
def exists(self):
|
def exists(self):
|
||||||
|
|
@ -29,14 +37,20 @@ def test_status(client, monkeypatch):
|
||||||
|
|
||||||
response = client.get("/status")
|
response = client.get("/status")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.get_json() == {"ping": "ok"}
|
assert response.get_json() == {"version": _version.__version__}
|
||||||
|
|
||||||
monkeypatch.setattr("humulus.home.get_db", MockDBTrue)
|
monkeypatch.setattr("humulus.home.get_db", MockDBTrue)
|
||||||
response = client.get("/status?couch=y")
|
response = client.get("/status?couch=y")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.get_json() == {"ping": "ok", "couch": "ok"}
|
assert response.get_json() == {
|
||||||
|
"version": _version.__version__,
|
||||||
|
"couch": "ok",
|
||||||
|
}
|
||||||
|
|
||||||
monkeypatch.setattr("humulus.home.get_db", MockDBFalse)
|
monkeypatch.setattr("humulus.home.get_db", MockDBFalse)
|
||||||
response = client.get("/status?couch=y")
|
response = client.get("/status?couch=y")
|
||||||
assert response.status_code == 500
|
assert response.status_code == 500
|
||||||
assert response.get_json() == {"ping": "ok", "couch": "not_exist"}
|
assert response.get_json() == {
|
||||||
|
"version": _version.__version__,
|
||||||
|
"couch": "not_exist",
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue