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

Commit 9a07ee4

Browse files
committed
Fix client construction in cloudant_bluemix context manager
Change `cloudant_user` and `auth_token` to positional arguments.
1 parent 094bc42 commit 9a07ee4

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
2.6.0 (Unreleased)
22
==================
3+
- [FIXED] Fixed client construction in ``cloudant_bluemix`` context manager.
34

45
2.5.0 (2017-07-06)
56
==================

src/cloudant/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ def cloudant_bluemix(vcap_services, instance_name=None, **kwargs):
122122
"""
123123
service = CloudFoundryService(vcap_services, instance_name)
124124
cloudant_session = Cloudant(
125-
username=service.username,
126-
password=service.password,
125+
service.username,
126+
service.password,
127127
url=service.url,
128128
**kwargs
129129
)

tests/unit/client_tests.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from requests import ConnectTimeout
3232

33-
from cloudant import cloudant, couchdb, couchdb_admin_party
33+
from cloudant import cloudant, cloudant_bluemix, couchdb, couchdb_admin_party
3434
from cloudant.client import Cloudant, CouchDB
3535
from cloudant.error import CloudantArgumentError, CloudantClientException
3636
from cloudant.feed import Feed, InfiniteFeed
@@ -502,7 +502,31 @@ def test_cloudant_context_helper(self):
502502
self.assertIsInstance(c.r_session, requests.Session)
503503
except Exception as err:
504504
self.fail('Exception {0} was raised.'.format(str(err)))
505-
505+
506+
def test_cloudant_bluemix_context_helper(self):
507+
"""
508+
Test that the cloudant_bluemix context helper works as expected.
509+
"""
510+
instance_name = 'Cloudant NoSQL DB-lv'
511+
vcap_services = {'cloudantNoSQLDB': [{
512+
'credentials': {
513+
'username': self.user,
514+
'password': self.pwd,
515+
'host': '{0}.cloudant.com'.format(self.account),
516+
'port': 443,
517+
'url': self.url
518+
},
519+
'name': instance_name,
520+
}]}
521+
522+
try:
523+
with cloudant_bluemix(vcap_services, instance_name=instance_name) as c:
524+
self.assertIsInstance(c, Cloudant)
525+
self.assertIsInstance(c.r_session, requests.Session)
526+
self.assertEquals(c.session()['userCtx']['name'], self.user)
527+
except Exception as err:
528+
self.fail('Exception {0} was raised.'.format(str(err)))
529+
506530
def test_constructor_with_account(self):
507531
"""
508532
Test instantiating a client object using an account name

0 commit comments

Comments
 (0)