Skip to content

Commit

Permalink
[#180] Test case for invalid design doc uri
Browse files Browse the repository at this point in the history
And using the new style str formatter.
  • Loading branch information
iblislin committed Nov 22, 2015
1 parent 31b6dec commit 68ffd15
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 2 additions & 4 deletions couchapp/clone_app.py
Expand Up @@ -21,14 +21,12 @@ def clone(source, dest=None, rev=None):
"""
Clone an application from a design_doc given.
:attr design_doc: dict, the design doc retrieved from couchdb
if something was wrong.
:param source: the http/https uri of design document
"""

try:
dburl, docid = source.split('_design/')
except ValueError:
raise AppError("%s isn't a valid source" % source)
raise AppError("{0} isn't a valid source".format(source))

if not dest:
dest = docid
Expand Down
17 changes: 17 additions & 0 deletions tests/test_clone_app.py
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-

from couchapp.clone_app import clone
from couchapp.errors import AppError

from mock import patch
from nose.tools import raises


@raises(AppError)
def test_invalid_source():
'''
Test case for clone(invalid_source)
If a source uri do not contain ``_design/``, it's invalid.
'''
clone('http://foo.bar')

0 comments on commit 68ffd15

Please sign in to comment.