mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 16:09:44 +00:00
Add version number
This commit is contained in:
parent
9b1a739347
commit
02b2f321a4
8 changed files with 121 additions and 29 deletions
|
|
@ -27,7 +27,7 @@ steps:
|
|||
- pip install codecov
|
||||
- codecov
|
||||
# Perform linting checks
|
||||
- black --check src tests
|
||||
- black --check src tests setup.py
|
||||
- flake8
|
||||
|
||||
---
|
||||
|
|
|
|||
44
setup.py
44
setup.py
|
|
@ -17,36 +17,38 @@ from os import path
|
|||
from setuptools import find_packages, setup
|
||||
|
||||
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()
|
||||
|
||||
# Get current version number
|
||||
version = {}
|
||||
with open(path.join(this_directory, "src/humulus/_version.py")) as f:
|
||||
exec(f.read(), version)
|
||||
|
||||
install_requires = [
|
||||
'Flask==1.0.3',
|
||||
'Flask-WTF==0.14.2',
|
||||
'simplejson==3.16.0',
|
||||
'python-slugify==3.0.2',
|
||||
'cloudant==2.12.0',
|
||||
"Flask==1.0.3",
|
||||
"Flask-WTF==0.14.2",
|
||||
"simplejson==3.16.0",
|
||||
"python-slugify==3.0.2",
|
||||
"cloudant==2.12.0",
|
||||
]
|
||||
|
||||
setup(
|
||||
name='humulus',
|
||||
version='0.0.1',
|
||||
url='https://github.com/shouptech/humulus',
|
||||
author='Mike Shoup',
|
||||
author_email='mike@shoup.io',
|
||||
description='Humulus is a beer recipe builder.',
|
||||
name="humulus",
|
||||
version=version["__version__"],
|
||||
url="https://github.com/shouptech/humulus",
|
||||
author="Mike Shoup",
|
||||
author_email="mike@shoup.io",
|
||||
description="Humulus is a beer recipe builder.",
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/x-rst',
|
||||
package_dir={'': 'src'},
|
||||
packages=find_packages(where='src'),
|
||||
long_description_content_type="text/x-rst",
|
||||
package_dir={"": "src"},
|
||||
packages=find_packages(where="src"),
|
||||
zip_safe=False,
|
||||
include_package_data=True,
|
||||
install_requires=install_requires,
|
||||
setup_requires=install_requires + [
|
||||
'pytest-runner',
|
||||
],
|
||||
tests_require=[
|
||||
'pytest',
|
||||
],
|
||||
setup_requires=install_requires + ["pytest-runner"],
|
||||
tests_require=["pytest"],
|
||||
classifiers=[],
|
||||
)
|
||||
|
|
|
|||
20
src/humulus/_version.py
Normal file
20
src/humulus/_version.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# 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.
|
||||
|
||||
import os
|
||||
|
||||
__version__ = "0.0.1"
|
||||
|
||||
if os.environ.get("DRONE_BUILD_NUMBER", default=None) is not None:
|
||||
__version__ += "dev{}".format(os.environ["DRONE_BUILD_NUMBER"])
|
||||
|
|
@ -28,6 +28,11 @@ def create_app(test_config=None):
|
|||
# Load config from configuration provided via ENV
|
||||
app.config.from_envvar("HUMULUS_SETTINGS")
|
||||
|
||||
# Load current version of humulus
|
||||
from . import _version
|
||||
|
||||
app.config["version"] = _version.__version__
|
||||
|
||||
from . import couch
|
||||
|
||||
couch.init_app(app)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,15 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# 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
|
||||
|
||||
|
|
@ -27,11 +35,20 @@ def index():
|
|||
return redirect(url_for("recipes.index"))
|
||||
|
||||
|
||||
@bp.route("/about")
|
||||
def about():
|
||||
"""Render the about page."""
|
||||
return render_template("about.html")
|
||||
|
||||
|
||||
@bp.route("/status")
|
||||
def status():
|
||||
status = {"version": current_app.config["version"]}
|
||||
if request.args.get("couch", default=False):
|
||||
if get_db().exists():
|
||||
return jsonify({"ping": "ok", "couch": "ok"}), 200
|
||||
status["couch"] = "ok"
|
||||
return jsonify(status), 200
|
||||
else:
|
||||
return jsonify({"ping": "ok", "couch": "not_exist"}), 500
|
||||
return jsonify({"ping": "ok"}), 200
|
||||
status["couch"] = "not_exist"
|
||||
return jsonify(status), 500
|
||||
return jsonify(status), 200
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
<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">
|
||||
{% if session.logged_in %}
|
||||
<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
|
||||
# limitations under the License.
|
||||
|
||||
from humulus import _version
|
||||
|
||||
|
||||
def test_home(client):
|
||||
response = client.get("/")
|
||||
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):
|
||||
class MockDBTrue:
|
||||
def exists(self):
|
||||
|
|
@ -29,14 +37,20 @@ def test_status(client, monkeypatch):
|
|||
|
||||
response = client.get("/status")
|
||||
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)
|
||||
response = client.get("/status?couch=y")
|
||||
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)
|
||||
response = client.get("/status?couch=y")
|
||||
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