mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 21:59:44 +00:00
62 lines
1.6 KiB
Python
62 lines
1.6 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 test recipe
|
|
put_doc({
|
|
'_id': 'awesome-lager',
|
|
'efficiency': '65',
|
|
'name': 'Awesome Lager',
|
|
'notes': 'Test',
|
|
'volume': '5.5'
|
|
})
|
|
|
|
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()
|