mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 18:29:41 +00:00
132 lines
3.8 KiB
Python
132 lines
3.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.
|
|
|
|
import uuid
|
|
|
|
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()))
|
|
app = create_app({
|
|
'COUCH_URL': 'http://127.0.0.1:5984',
|
|
'COUCH_USERNAME': 'admin',
|
|
'COUCH_PASSWORD': 'password',
|
|
'COUCH_DATABASE': dbname,
|
|
'WTF_CSRF_ENABLED': False,
|
|
'SECRET_KEY': 'testing'
|
|
})
|
|
|
|
with app.app_context():
|
|
# Create the database
|
|
build_couch()
|
|
# Add a test doc
|
|
put_doc({'data': 'test', '_id': 'foobar'})
|
|
|
|
# Add a couple test recipe
|
|
put_doc({
|
|
'_id': 'awesome-lager',
|
|
'$type': 'recipe',
|
|
'efficiency': '65',
|
|
'name': 'Awesome Lager',
|
|
'notes': 'Test',
|
|
'volume': '5.5',
|
|
'fermentables': [],
|
|
'hops': []
|
|
})
|
|
put_doc({
|
|
'_id': 'partial-yeast-recipe',
|
|
'$type': 'recipe',
|
|
'efficiency': '75',
|
|
'name': 'Partial Beer',
|
|
'notes': 'Contains only required fields for yeast.',
|
|
'volume': '3.5',
|
|
'fermentables': [],
|
|
'hops': [],
|
|
'yeast': {
|
|
'name': 'US-05',
|
|
'low_attenuation': '60',
|
|
'high_attenuation': '72',
|
|
}
|
|
})
|
|
put_doc({
|
|
'_id': 'full-recipe',
|
|
'$type': 'recipe',
|
|
'efficiency': '78',
|
|
'name': 'Awesome Beer',
|
|
'notes': 'This is a test beer that contains most possible fields.',
|
|
'volume': '2.5',
|
|
'fermentables': [
|
|
{
|
|
'name': '2row',
|
|
'type': 'Grain',
|
|
'amount': '5',
|
|
'ppg': '37',
|
|
'color': '2'
|
|
},
|
|
{
|
|
'name': 'Dextrose',
|
|
'type': 'Sugar',
|
|
'amount': '1',
|
|
'ppg': '46',
|
|
'color': '1'
|
|
}
|
|
],
|
|
'hops': [
|
|
{
|
|
'name': 'Nugget (US)',
|
|
'use': 'Boil',
|
|
'alpha': '12.5',
|
|
'duration': '60',
|
|
'amount': '1'
|
|
},
|
|
{
|
|
'name': 'CTZ (US)',
|
|
'use': 'Dry-Hop',
|
|
'alpha': '16',
|
|
'duration': '5',
|
|
'amount': '0.5'
|
|
}
|
|
],
|
|
'yeast': {
|
|
'name': 'Northern California Ale',
|
|
'type': 'Liquid',
|
|
'lab': 'Inland Island',
|
|
'code': 'INIS-001',
|
|
'flocculation': 'Medium',
|
|
'low_attenuation': '73',
|
|
'high_attenuation': '77',
|
|
'min_temperature': '60',
|
|
'max_temperature': '72',
|
|
'abv_tolerance': '10'
|
|
}
|
|
})
|
|
|
|
yield app
|
|
|
|
with app.app_context():
|
|
get_couch().delete_database(dbname)
|
|
|
|
|
|
@pytest.fixture
|
|
def runner(app):
|
|
return app.test_cli_runner()
|
|
|
|
|
|
@pytest.fixture
|
|
def client(app):
|
|
return app.test_client()
|