mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 16:09:44 +00:00
Flake8 fixes for tests
This commit is contained in:
parent
756be12a2a
commit
c219ae3301
6 changed files with 27 additions and 25 deletions
|
|
@ -20,6 +20,7 @@ import pytest
|
||||||
from humulus import create_app
|
from humulus import create_app
|
||||||
from humulus.couch import build_couch, get_couch, put_doc
|
from humulus.couch import build_couch, get_couch, put_doc
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def app():
|
def app():
|
||||||
dbname = 'test_{}'.format(str(uuid.uuid4()))
|
dbname = 'test_{}'.format(str(uuid.uuid4()))
|
||||||
|
|
@ -126,7 +127,8 @@ def app():
|
||||||
})
|
})
|
||||||
|
|
||||||
# Add a test style
|
# Add a test style
|
||||||
put_doc({'$type': 'style',
|
put_doc({
|
||||||
|
'$type': 'style',
|
||||||
'_id': '1A',
|
'_id': '1A',
|
||||||
'abv': {'high': '100', 'low': '0'},
|
'abv': {'high': '100', 'low': '0'},
|
||||||
'appearance': 'Good looking',
|
'appearance': 'Good looking',
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@
|
||||||
# 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 session
|
|
||||||
|
|
||||||
|
|
||||||
def test_login(client, auth):
|
def test_login(client, auth):
|
||||||
# Test GET
|
# Test GET
|
||||||
|
|
@ -43,6 +41,7 @@ def test_login(client, auth):
|
||||||
assert session['logged_in']
|
assert session['logged_in']
|
||||||
assert session.permanent
|
assert session.permanent
|
||||||
|
|
||||||
|
|
||||||
def test_logout(client, auth):
|
def test_logout(client, auth):
|
||||||
# Login
|
# Login
|
||||||
auth.login()
|
auth.login()
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,9 @@
|
||||||
# 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.
|
||||||
|
|
||||||
import uuid
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from humulus.couch import *
|
from humulus.couch import put_doc, get_doc, update_doc, put_designs, get_view
|
||||||
|
|
||||||
|
|
||||||
def test_put_doc(app):
|
def test_put_doc(app):
|
||||||
|
|
@ -73,7 +72,7 @@ def test_put_designs(app, monkeypatch):
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
# Test initial load of designs
|
# Test initial load of designs
|
||||||
monkeypatch.setattr(Path, 'parent', testpath/'assets/initial')
|
monkeypatch.setattr(Path, 'parent', testpath / 'assets/initial')
|
||||||
put_designs()
|
put_designs()
|
||||||
|
|
||||||
recipes = get_doc('_design/recipes')
|
recipes = get_doc('_design/recipes')
|
||||||
|
|
@ -86,7 +85,7 @@ def test_put_designs(app, monkeypatch):
|
||||||
assert recipes['_rev'] == rev
|
assert recipes['_rev'] == rev
|
||||||
|
|
||||||
# Test that changes can be loaded
|
# Test that changes can be loaded
|
||||||
monkeypatch.setattr(Path, 'parent', testpath/'assets/changed')
|
monkeypatch.setattr(Path, 'parent', testpath / 'assets/changed')
|
||||||
put_designs()
|
put_designs()
|
||||||
recipes = get_doc('_design/recipes')
|
recipes = get_doc('_design/recipes')
|
||||||
assert 'by-date' in recipes['views']
|
assert 'by-date' in recipes['views']
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from humulus.filters import *
|
from humulus.filters import (recipe_abv, recipe_fg, recipe_ibu, sort_hops,
|
||||||
|
recipe_ibu_ratio, recipe_og, recipe_srm, ferm_pct)
|
||||||
from humulus.recipes import HopForm
|
from humulus.recipes import HopForm
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import json
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from humulus.couch import get_db, get_doc, put_doc
|
from humulus.couch import get_doc
|
||||||
from humulus.recipes import FermentableForm, HopForm, RecipeForm, YeastForm
|
from humulus.recipes import FermentableForm, HopForm, RecipeForm, YeastForm
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -41,7 +41,6 @@ def test_index(client):
|
||||||
response.data
|
response.data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Test sort by name descending
|
# Test sort by name descending
|
||||||
response = client.get('/recipes/?descending=true&sort_by=name')
|
response = client.get('/recipes/?descending=true&sort_by=name')
|
||||||
assert (
|
assert (
|
||||||
|
|
@ -119,6 +118,7 @@ def test_index(client):
|
||||||
response.data
|
response.data
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_create(client, app, auth):
|
def test_create(client, app, auth):
|
||||||
"""Test success in creating a recipe document."""
|
"""Test success in creating a recipe document."""
|
||||||
# Test GET without login
|
# Test GET without login
|
||||||
|
|
@ -203,7 +203,7 @@ def test_update(client, app, auth):
|
||||||
query_string={'rev': ''}, data=doc)
|
query_string={'rev': ''}, data=doc)
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
with client.session_transaction() as session:
|
with client.session_transaction() as session:
|
||||||
flash_message = dict(session['_flashes']).pop('danger', None)
|
flash_message = dict(session['_flashes']).pop('danger', None)
|
||||||
assert 'Update conflict' in flash_message
|
assert 'Update conflict' in flash_message
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,20 +145,21 @@ def test_import_styles(monkeypatch):
|
||||||
monkeypatch.setattr('humulus.styles.put_doc', fake_put_doc)
|
monkeypatch.setattr('humulus.styles.put_doc', fake_put_doc)
|
||||||
|
|
||||||
import_styles(None)
|
import_styles(None)
|
||||||
assert PutRecorder.doc == {'$type': 'style',
|
assert PutRecorder.doc == {
|
||||||
'_id': '1A',
|
'$type': 'style',
|
||||||
'abv': {'high': '100', 'low': '0'},
|
'_id': '1A',
|
||||||
'appearance': 'Good looking',
|
'abv': {'high': '100', 'low': '0'},
|
||||||
'aroma': 'Smelly',
|
'appearance': 'Good looking',
|
||||||
'fg': {'high': '1.2', 'low': '1.0'},
|
'aroma': 'Smelly',
|
||||||
'flavor': 'Good tasting',
|
'fg': {'high': '1.2', 'low': '1.0'},
|
||||||
'ibu': {'high': '100', 'low': '0'},
|
'flavor': 'Good tasting',
|
||||||
'impression': 'Refreshing',
|
'ibu': {'high': '100', 'low': '0'},
|
||||||
'mouthfeel': 'Good feeling',
|
'impression': 'Refreshing',
|
||||||
'name': 'Test Style',
|
'mouthfeel': 'Good feeling',
|
||||||
'og': {'high': '1.2', 'low': '1.0'},
|
'name': 'Test Style',
|
||||||
'srm': {'high': '100', 'low': '0'}
|
'og': {'high': '1.2', 'low': '1.0'},
|
||||||
}
|
'srm': {'high': '100', 'low': '0'}
|
||||||
|
}
|
||||||
|
|
||||||
MockDB.db = {'1A': ''}
|
MockDB.db = {'1A': ''}
|
||||||
PutRecorder.doc = None
|
PutRecorder.doc = None
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue