1
0
Fork 0
mirror of https://github.com/shouptech/humulus.git synced 2026-02-03 15:59:43 +00:00
humulus/tests/test_recipes.py

50 lines
1.5 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.couch import get_db
def test_create(client, app):
# Test GET
response = client.get('/recipes/create')
assert response.status_code == 200
# Test POST
data = {
'efficiency': '65',
'name': 'Test',
'notes': 'Test',
'volume': '5.5'
}
response = client.post('/recipes/create', data=data)
assert response.status_code == 302
with app.app_context():
doc = get_db()['test']
assert doc['name'] == 'Test'
assert doc['notes'] == 'Test'
assert doc['volume'] == '5.5'
assert doc['efficiency'] == '65'
def test_info(client):
# Validate 404
response = client.get('/recipes/info/thisdoesnotexist')
assert response.status_code == 404
# Validate response for existing doc
response = client.get('/recipes/info/awesome-lager')
assert response.status_code == 200
assert b'Awesome Lager' in response.data