本文整理汇总了Python中cloudant.account.Cloudant.delete_database方法的典型用法代码示例。如果您正苦于以下问题:Python Cloudant.delete_database方法的具体用法?Python Cloudant.delete_database怎么用?Python Cloudant.delete_database使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudant.account.Cloudant
的用法示例。
在下文中一共展示了Cloudant.delete_database方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_delete_methods
# 需要导入模块: from cloudant.account import Cloudant [as 别名]
# 或者: from cloudant.account.Cloudant import delete_database [as 别名]
def test_create_delete_methods(self):
mock_resp = mock.Mock()
mock_resp.json = mock.Mock()
mock_resp.json.return_value = {}
mock_resp.text = "mock response"
mock_resp.status_code = 201
mock_del = mock.Mock()
mock_del.status_code = 200
mock_get = mock.Mock()
mock_get.status_code = 404
self.mock_instance.put.return_value = mock_resp
self.mock_instance.delete.return_value = mock_del
self.mock_instance.get.return_value = mock_get
# instantiate and connect
c = Cloudant(self.username, self.password)
c.connect()
self.failUnless(self.mock_session.called)
# create db call
c.create_database("unittest")
self.mock_instance.get.assert_has_calls(
mock.call('https://steve.cloudant.com/unittest')
)
self.mock_instance.put.assert_has_calls(
mock.call('https://steve.cloudant.com/unittest')
)
# delete db call
mock_get.reset_mocks()
mock_get.status_code = 200
c.delete_database("unittest")
self.mock_instance.get.assert_has_calls(
mock.call('https://steve.cloudant.com/unittest')
)
self.mock_instance.delete.assert_has_calls(
mock.call('https://steve.cloudant.com/unittest')
)
# create existing db fails
mock_get.reset_mocks()
mock_get.status_code = 200
self.assertRaises(CloudantException, c.create_database, "unittest")
# delete non-existing db fails
mock_get.reset_mocks()
mock_get.status_code = 404
self.assertRaises(CloudantException, c.delete_database, "unittest")