1
0
Fork 0
mirror of https://github.com/shouptech/humulus.git synced 2026-02-03 23:29:42 +00:00

Compare commits

..

No commits in common. "c219ae3301eedf37c62a1ed00cb8ac23bba33ce3" and "b911dc9c531b4fd9bbeb4e3630a7600c3f820df1" have entirely different histories.

12 changed files with 53 additions and 61 deletions

View file

@ -13,5 +13,3 @@
# limitations under the License.
from humulus.app import create_app
__all__ = ['create_app', ]

View file

@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from flask import Flask, render_template

View file

@ -26,7 +26,6 @@ from flask import abort, current_app, g
from flask.cli import with_appcontext
from slugify import slugify
def get_couch():
"""Connect to the configured CouchDB."""
if 'couch' not in g:

View file

@ -123,11 +123,9 @@ def sort_hops(hops, form=False):
by_use[hop['use']].append(hop)
if form:
def key(hop):
return float(hop.duration.data)
key = lambda hop: float(hop.duration.data)
else:
def key(hop):
return float(hop['duration'])
key = lambda hop: float(hop['duration'])
hops_sorted = sorted(by_use['FWH'], key=key, reverse=True)
hops_sorted.extend(sorted(by_use['Boil'], key=key, reverse=True))

View file

@ -37,8 +37,8 @@ bp = Blueprint('recipes', __name__, url_prefix='/recipes')
class FermentableForm(Form):
"""Form for fermentables.
CSRF is disabled for this form.yeast.form (using `Form as parent class)
because it is never used by itself.
CSRF is disabled for this form.yeast.form (using `Form as parent class) because it
is never used by itself.
"""
name = StringField('Name', validators=[DataRequired()])
type = SelectField('Type', validators=[DataRequired()],
@ -67,8 +67,8 @@ class FermentableForm(Form):
class HopForm(Form):
"""Form for hops.
CSRF is disabled for this form.yeast.form (using `Form as parent class)
because it is never used by itself.
CSRF is disabled for this form.yeast.form (using `Form as parent class) because it
is never used by itself.
"""
name = StringField('Name', validators=[DataRequired()])
use = SelectField('Usage', validators=[DataRequired()],
@ -96,8 +96,8 @@ class HopForm(Form):
class YeastForm(Form):
"""Form for yeast.
CSRF is disabled for this form.yeast.form (using `Form as parent class)
because it is never used by itself.
CSRF is disabled for this form.yeast.form (using `Form as parent class) because it
is never used by itself.
"""
name = StringField('Name', validators=[Optional()])
type = SelectField('Type', default='',

View file

@ -65,8 +65,7 @@ def sub_to_doc(sub):
doc['ibu']['low'] = (sub.find('./stats/ibu/low').text
if sub.find('./stats/ibu/low') is not None else '0')
doc['ibu']['high'] = (sub.find('./stats/ibu/high').text
if sub.find('./stats/ibu/high') is not None
else '100')
if sub.find('./stats/ibu/high') is not None else '100')
doc['og']['low'] = (sub.find('./stats/og/low').text
if sub.find('./stats/og/low') is not None else '1.0')
doc['og']['high'] = (sub.find('./stats/og/high').text
@ -78,13 +77,11 @@ def sub_to_doc(sub):
doc['srm']['low'] = (sub.find('./stats/srm/low').text
if sub.find('./stats/srm/low') is not None else '0')
doc['srm']['high'] = (sub.find('./stats/srm/high').text
if sub.find('./stats/srm/high') is not None
else '100')
if sub.find('./stats/srm/high') is not None else '100')
doc['abv']['low'] = (sub.find('./stats/abv/low').text
if sub.find('./stats/abv/low') is not None else '0')
doc['abv']['high'] = (sub.find('./stats/abv/high').text
if sub.find('./stats/abv/high') is not None
else '100')
if sub.find('./stats/abv/high') is not None else '100')
return doc

View file

@ -20,7 +20,6 @@ import pytest
from humulus import create_app
from humulus.couch import build_couch, get_couch, put_doc
@pytest.fixture
def app():
dbname = 'test_{}'.format(str(uuid.uuid4()))
@ -127,8 +126,7 @@ def app():
})
# Add a test style
put_doc({
'$type': 'style',
put_doc({'$type': 'style',
'_id': '1A',
'abv': {'high': '100', 'low': '0'},
'appearance': 'Good looking',

View file

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from flask import session
def test_login(client, auth):
# Test GET
@ -41,7 +43,6 @@ def test_login(client, auth):
assert session['logged_in']
assert session.permanent
def test_logout(client, auth):
# Login
auth.login()

View file

@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid
from pathlib import Path
from humulus.couch import put_doc, get_doc, update_doc, put_designs, get_view
from humulus.couch import *
def test_put_doc(app):

View file

@ -14,8 +14,7 @@
from decimal import Decimal
from humulus.filters import (recipe_abv, recipe_fg, recipe_ibu, sort_hops,
recipe_ibu_ratio, recipe_og, recipe_srm, ferm_pct)
from humulus.filters import *
from humulus.recipes import HopForm

View file

@ -16,7 +16,7 @@ import json
from decimal import Decimal
from io import BytesIO
from humulus.couch import get_doc
from humulus.couch import get_db, get_doc, put_doc
from humulus.recipes import FermentableForm, HopForm, RecipeForm, YeastForm
@ -41,6 +41,7 @@ def test_index(client):
response.data
)
# Test sort by name descending
response = client.get('/recipes/?descending=true&sort_by=name')
assert (
@ -118,7 +119,6 @@ def test_index(client):
response.data
)
def test_create(client, app, auth):
"""Test success in creating a recipe document."""
# Test GET without login

View file

@ -145,8 +145,7 @@ def test_import_styles(monkeypatch):
monkeypatch.setattr('humulus.styles.put_doc', fake_put_doc)
import_styles(None)
assert PutRecorder.doc == {
'$type': 'style',
assert PutRecorder.doc == {'$type': 'style',
'_id': '1A',
'abv': {'high': '100', 'low': '0'},
'appearance': 'Good looking',