# 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'