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

Add get_view function

This commit is contained in:
Emma 2019-06-28 10:50:41 -06:00
parent 44bdfc1413
commit 28b788fa76
2 changed files with 13 additions and 1 deletions

View file

@ -21,6 +21,7 @@ from pathlib import Path
import click
from cloudant import CouchDB
from cloudant.view import View
from flask import abort, current_app, g
from flask.cli import with_appcontext
from slugify import slugify
@ -151,3 +152,8 @@ def put_designs():
doc.save()
else:
put_doc(data)
def get_view(doc_name, view_name):
"""Return a cloudant.View object matching the specified name."""
return View(get_doc(doc_name), view_name)

View file

@ -15,7 +15,7 @@
import uuid
from pathlib import Path
from humulus.couch import get_doc, put_doc, update_doc, put_designs
from humulus.couch import *
def test_put_doc(app):
@ -90,3 +90,9 @@ def test_put_designs(app, monkeypatch):
put_designs()
recipes = get_doc('_design/recipes')
assert 'by-date' in recipes['views']
def test_get_view(app):
with app.app_context():
view = get_view('_design/recipes', 'by-date')
assert view()['total_rows'] > 0