1
0
Fork 0
mirror of https://github.com/shouptech/humulus.git synced 2026-02-03 23:09:41 +00:00
humulus/tests/test_couch.py

51 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.
import uuid
from humulus.couch import get_doc, put_doc
def test_put_doc(app):
with app.app_context():
data = {'foo': 'bar'}
response = put_doc(data)
assert '_id' in response
response = put_doc({'name': 'test'})
assert response['_id'] == 'test'
response = put_doc({'name': 'test'})
assert response['_id'] == 'test-1'
response = put_doc({'name': 'test'})
assert response['_id'] == 'test-2'
def test_build_couch_command(runner, monkeypatch):
class Recorder(object):
called = False
def fake_build_couch():
Recorder.called = True
monkeypatch.setattr('humulus.couch.build_couch', fake_build_couch)
result = runner.invoke(args=['build-couch'])
assert 'Built a couch. Please have a seat.' in result.output
assert Recorder.called
def test_get_doc(app):
with app.app_context():
assert get_doc('foobar')['data'] == 'test'