From 4c3d78ce4f64b57273621a3cd7f6c5232fb120bf Mon Sep 17 00:00:00 2001 From: Mike Shoup Date: Tue, 9 Jul 2019 12:35:31 -0600 Subject: [PATCH] Add test for styles.recipes endpoint --- src/humulus/styles.py | 6 +----- tests/test_styles.py | 7 +++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/humulus/styles.py b/src/humulus/styles.py index 533defc..c7c4334 100644 --- a/src/humulus/styles.py +++ b/src/humulus/styles.py @@ -172,9 +172,5 @@ def info(id): def recipes(id): style = get_doc_or_404(id) view = get_view('_design/recipes', 'by-style') - try: - rows = view(include_docs=True, descending=True, key=id)['rows'] - except requests.exceptions.HTTPError: - abort(400) - + rows = view(include_docs=True, descending=True, key=id)['rows'] return render_template('styles/recipes.html', style=style, rows=rows) diff --git a/tests/test_styles.py b/tests/test_styles.py index 23c3933..80a07bc 100644 --- a/tests/test_styles.py +++ b/tests/test_styles.py @@ -219,3 +219,10 @@ def test_info(auth, client): assert response.status_code == 200 assert b'1A' in response.data assert b'Test Style' in response.data + + +def test_recipes(client): + """Test success in retrieving list of recipes matching style.""" + response = client.get('/styles/info/1A/recipes') + assert response.status_code == 200 + assert b'Awesome Beer' in response.data