mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 23:09:41 +00:00
* Add Jinja filters for specifications * Include tests for Jinja filters * Javascript to handle form changes. * Add footer for displaying specs on recipe forms * Don't build docker on pull requests
73 lines
2.8 KiB
Python
73 lines
2.8 KiB
Python
# 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.
|
|
|
|
|
|
from humulus.filters import *
|
|
|
|
|
|
def test_recipe_og(sample_recipes):
|
|
assert recipe_og(sample_recipes['lager']) == '1.054'
|
|
assert recipe_og(sample_recipes['sweetstout']) == '1.038'
|
|
# Remove fermentables, verify 0 is returned
|
|
sample_recipes['lager'].pop('fermentables')
|
|
assert recipe_og(sample_recipes['lager']) == '0.000'
|
|
|
|
|
|
def test_recipe_fg(sample_recipes):
|
|
assert recipe_fg(sample_recipes['lager']) == '1.014'
|
|
assert recipe_fg(sample_recipes['sweetstout']) == '1.015'
|
|
# Remove fermentables, verify 0 is returned
|
|
sample_recipes['lager'].pop('fermentables')
|
|
assert recipe_fg(sample_recipes['lager']) == '0.000'
|
|
# Remove yeast, verify 0 is returned
|
|
sample_recipes['sweetstout'].pop('yeast')
|
|
assert recipe_fg(sample_recipes['sweetstout']) == '0.000'
|
|
|
|
|
|
def test_recipe_ibu(sample_recipes):
|
|
assert recipe_ibu(sample_recipes['lager']) == '26'
|
|
assert recipe_ibu(sample_recipes['sweetstout']) == '34'
|
|
# Remove hops, verify 0 is returned
|
|
sample_recipes['lager'].pop('hops')
|
|
assert recipe_ibu(sample_recipes['lager']) == '0'
|
|
|
|
|
|
def test_recipe_ibu_ratio(sample_recipes):
|
|
assert recipe_ibu_ratio(sample_recipes['lager']) == '0.48'
|
|
assert recipe_ibu_ratio(sample_recipes['sweetstout']) == '0.89'
|
|
# Remove fermentables, verify 0 is returned
|
|
sample_recipes['lager'].pop('fermentables')
|
|
assert recipe_ibu_ratio(sample_recipes['lager']) == '0'
|
|
# Remove hops, verify 0 is returned
|
|
sample_recipes['sweetstout'].pop('hops')
|
|
assert recipe_ibu_ratio(sample_recipes['sweetstout']) == '0'
|
|
|
|
|
|
def test_recipe_abv(sample_recipes):
|
|
assert recipe_abv(sample_recipes['lager']) == '5.3'
|
|
assert recipe_abv(sample_recipes['sweetstout']) == '3.0'
|
|
# Remove fermentables, verify 0 is returned
|
|
sample_recipes['lager'].pop('fermentables')
|
|
assert recipe_abv(sample_recipes['lager']) == '0'
|
|
# Remove yeast, verify 0 is returned
|
|
sample_recipes['sweetstout'].pop('yeast')
|
|
assert recipe_abv(sample_recipes['sweetstout']) == '0'
|
|
|
|
|
|
def test_recipe_srm(sample_recipes):
|
|
assert recipe_srm(sample_recipes['lager']) == '3'
|
|
assert recipe_srm(sample_recipes['sweetstout']) == '21'
|
|
# Remove fermentables, verify 0 is returned
|
|
sample_recipes['lager'].pop('fermentables')
|
|
assert recipe_srm(sample_recipes['lager']) == '0'
|