mirror of
https://github.com/shouptech/humulus.git
synced 2026-02-03 20:49:44 +00:00
Add get_view function
This commit is contained in:
parent
44bdfc1413
commit
28b788fa76
2 changed files with 13 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ from pathlib import Path
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from cloudant import CouchDB
|
from cloudant import CouchDB
|
||||||
|
from cloudant.view import View
|
||||||
from flask import abort, current_app, g
|
from flask import abort, current_app, g
|
||||||
from flask.cli import with_appcontext
|
from flask.cli import with_appcontext
|
||||||
from slugify import slugify
|
from slugify import slugify
|
||||||
|
|
@ -151,3 +152,8 @@ def put_designs():
|
||||||
doc.save()
|
doc.save()
|
||||||
else:
|
else:
|
||||||
put_doc(data)
|
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)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
import uuid
|
import uuid
|
||||||
from pathlib import Path
|
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):
|
def test_put_doc(app):
|
||||||
|
|
@ -90,3 +90,9 @@ def test_put_designs(app, monkeypatch):
|
||||||
put_designs()
|
put_designs()
|
||||||
recipes = get_doc('_design/recipes')
|
recipes = get_doc('_design/recipes')
|
||||||
assert 'by-date' in recipes['views']
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue