本文整理汇总了Python中cloudant.account.Cloudant.session_cookie方法的典型用法代码示例。如果您正苦于以下问题:Python Cloudant.session_cookie方法的具体用法?Python Cloudant.session_cookie怎么用?Python Cloudant.session_cookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudant.account.Cloudant
的用法示例。
在下文中一共展示了Cloudant.session_cookie方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_session_calls
# 需要导入模块: from cloudant.account import Cloudant [as 别名]
# 或者: from cloudant.account.Cloudant import session_cookie [as 别名]
def test_session_calls(self):
"""test session related methods"""
c = Cloudant(
self.username,
self.password,
url='https://steve.cloudant.com',
x_cloudant_user=self.username
)
c.connect()
self.assertTrue(self.mock_session.called)
self.assertEqual(
self.mock_instance.auth,
(self.username, self.password)
)
self.assertEqual(
self.mock_instance.headers['X-Cloudant-User'],
self.username
)
self.assertIsNotNone(self.mock_instance.headers['User-Agent'])
self.assertEqual('COOKIE', c.session_cookie())
self.assertTrue(self.mock_instance.get.called)
self.mock_instance.get.assert_has_calls(
[ mock.call('https://steve.cloudant.com/_session') ]
)
self.assertTrue(self.mock_instance.post.called)
self.mock_instance.post.assert_has_calls(
[ mock.call(
'https://steve.cloudant.com/_session',
headers={'Content-Type': 'application/x-www-form-urlencoded'},
data={'password': 'abc123', 'name': 'steve'}
) ]
)
c.disconnect()
self.assertTrue(self.mock_instance.delete.called)
self.mock_instance.delete.assert_has_calls(
[ mock.call('https://steve.cloudant.com/_session') ]
)
示例2: test_session_calls
# 需要导入模块: from cloudant.account import Cloudant [as 别名]
# 或者: from cloudant.account.Cloudant import session_cookie [as 别名]
def test_session_calls(self):
"""test session related methods"""
c = Cloudant(self.username, self.password)
c.connect()
self.failUnless(self.mock_session.called)
self.assertEqual(
self.mock_instance.auth,
(self.username, self.password)
)
self.assertEqual(
self.mock_instance.headers,
{'X-Cloudant-User': self.username}
)
self.assertEqual('COOKIE', c.session_cookie())
self.failUnless(self.mock_instance.get.called)
self.mock_instance.get.assert_has_calls(
mock.call('https://steve.cloudant.com/_session')
)
self.failUnless(self.mock_instance.post.called)
self.mock_instance.post.assert_has_calls(
mock.call(
'https://steve.cloudant.com/_session',
headers={'Content-Type': 'application/x-www-form-urlencoded'},
data={'password': 'abc123', 'name': 'steve'}
)
)
c.disconnect()
self.failUnless(self.mock_instance.delete.called)
self.mock_instance.delete.assert_has_calls(
mock.call('https://steve.cloudant.com/_session')
)