Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 7769375

Browse files
committed
Added skip_if_iam to skip tests when running with IAM auth
1 parent 4cd1807 commit 7769375

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

tests/unit/database_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from cloudant.feed import Feed, InfiniteFeed
3939
from tests.unit._test_util import LONG_NUMBER
4040

41-
from .unit_t_db_base import skip_if_not_cookie_auth, UnitTestDbBase
41+
from .unit_t_db_base import skip_if_not_cookie_auth, UnitTestDbBase, skip_if_iam
4242
from .. import unicode_
4343

4444
class CloudantDatabaseExceptionTests(unittest.TestCase):
@@ -863,7 +863,7 @@ def test_get_show_result(self):
863863
resp,
864864
'Hello from doc001!'
865865
)
866-
866+
@skip_if_iam
867867
def test_create_doc_with_update_handler(self):
868868
"""
869869
Test update_handler_result executes an update handler function
@@ -884,6 +884,7 @@ def test_create_doc_with_update_handler(self):
884884
'Created new doc: {"message":"hello","_id":"testDoc"}'
885885
)
886886

887+
@skip_if_iam
887888
def test_update_doc_with_update_handler(self):
888889
"""
889890
Test update_handler_result executes an update handler function

tests/unit/design_document_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from cloudant.view import View, QueryIndexView
3333
from cloudant.error import CloudantArgumentError, CloudantDesignDocumentException
3434

35-
from .unit_t_db_base import UnitTestDbBase
35+
from .unit_t_db_base import UnitTestDbBase, skip_if_iam
3636

3737
class CloudantDesignDocumentExceptionTests(unittest.TestCase):
3838
"""
@@ -1252,6 +1252,7 @@ def test_get_search_index(self):
12521252
'{"store": true}); }\n}'}
12531253
)
12541254

1255+
@skip_if_iam
12551256
def test_rewrite_rule(self):
12561257
"""
12571258
Test that design document URL is rewritten to the expected test document.

tests/unit/unit_t_db_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ def wrapper(*args):
7878
return wrapper
7979

8080

81+
def skip_if_iam(f):
82+
def wrapper(*args):
83+
if os.environ.get('IAM_API_KEY'):
84+
raise unittest.SkipTest('Test only supports non-IAM authentication')
85+
return f(*args)
86+
return wrapper
87+
8188
class UnitTestDbBase(unittest.TestCase):
8289
"""
8390
The base class for all unit tests targeting a database

0 commit comments

Comments
 (0)