1
0
Fork 0
mirror of https://github.com/shouptech/humulus.git synced 2026-02-03 22:19:42 +00:00

Compare commits

..

11 commits

Author SHA1 Message Date
cc4ed2bef9 Add ability to put a document from a file 2019-06-27 16:24:10 -06:00
17bf2ff722 Add codecov badge 2019-06-27 13:24:14 -06:00
792761e801 Add codecov 2019-06-27 13:21:47 -06:00
8813fb766a Add couchurl as env variable 2019-06-27 13:18:19 -06:00
a81562f379 fix test config 2019-06-27 13:17:03 -06:00
243b8d839b Curl correct url 2019-06-27 13:13:28 -06:00
88644894f9 Launch couch as a service 2019-06-27 13:11:57 -06:00
5d8f536cb6 Detach couch container 2019-06-27 13:07:21 -06:00
7f28223deb Add test configuration 2019-06-27 13:04:19 -06:00
4c81a8580c Fix yaml 2019-06-27 12:56:51 -06:00
5794922546 Add build status image 2019-06-27 12:56:17 -06:00
6 changed files with 55 additions and 3 deletions

View file

@ -1,11 +1,29 @@
kind: pipeline
name: default
services:
- name: couchdb
image: couchdb:2.3
environment:
COUCHDB_USER: admin
COUCHDB_PASSWORD: password
steps:
- test
- name: test
image: python:3.6
environment:
COUCH_URL: 'http://couchdb:5984'
CODECOV_TOKEN:
from_secret: CODECOV_TOKEN
commands:
# Install pre-requisites
- pip install coverage pytest
- pip install -e .
# Wait for couch
- until curl "$COUCH_URL" ; do sleep 1 ; done
# Run tests
- coverage run -m pytest
- coverage report -m
# Upload coverage report
- pip install codecov
- codecov

View file

@ -1,3 +1,11 @@
.. image:: https://drone.shoup.io/api/badges/shouptech/humulus/status.svg
:target: https://drone.shoup.io/shouptech/humulus
:alt: Drone build status
.. image:: https://codecov.io/gh/shouptech/humulus/branch/master/graph/badge.svg
:target: https://codecov.io/gh/shouptech/humulus
:alt: Code Coverage
Humulus is an open-source homebrew beer recipe app built using Flask.
Humulus is currently very much WIP and probably doesn't actually work.

View file

@ -15,6 +15,7 @@
# limitations under the License.
from datetime import datetime
import json
import uuid
import click
@ -118,3 +119,13 @@ def get_doc_or_404(id):
except KeyError:
abort(404)
return doc
def put_doc_from_file(filename):
"""Loads filename and stores it in couch.
The file must be valid JSON.
"""
with open(filename, 'r') as doc:
response = put_doc(json.load(doc))
return response

View file

@ -0,0 +1,4 @@
{
"_id": "testfile",
"foo": "bar"
}

View file

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import uuid
import pytest
@ -22,8 +23,9 @@ from humulus.couch import build_couch, get_couch, put_doc
@pytest.fixture
def app():
dbname = 'test_{}'.format(str(uuid.uuid4()))
couchurl = os.environ.get('COUCH_URL', 'http://127.0.0.1:5984')
app = create_app({
'COUCH_URL': 'http://127.0.0.1:5984',
'COUCH_URL': couchurl,
'COUCH_USERNAME': 'admin',
'COUCH_PASSWORD': 'password',
'COUCH_DATABASE': dbname,

View file

@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import pathlib
import uuid
from humulus.couch import get_doc, put_doc, update_doc
from humulus.couch import get_doc, put_doc, update_doc, put_doc_from_file
def test_put_doc(app):
@ -64,3 +65,11 @@ def test_build_couch_command(runner, monkeypatch):
def test_get_doc(app):
with app.app_context():
assert get_doc('foobar')['data'] == 'test'
def test_put_doc_from_file(app):
here = pathlib.Path(__file__).parent
with app.app_context():
response = put_doc_from_file(here/'assets'/'test_doc.json')
assert response['_id'] == 'testfile'
assert response['foo'] == 'bar'