コード例 #1
0
 def test_raise_with_proper_code_and_args(self):
     """
     Ensure that the requested exception is raised.
     """
     with self.assertRaises(CloudantClientException) as cm:
         raise CloudantClientException(404, 'foo')
     self.assertEqual(cm.exception.status_code, 404)
コード例 #2
0
 def test_raise_without_code(self):
     """
     Ensure that a default exception/code is used if none is provided.
     """
     with self.assertRaises(CloudantClientException) as cm:
         raise CloudantClientException()
     self.assertEqual(cm.exception.status_code, 100)
コード例 #3
0
 def test_raise_using_invalid_code(self):
     """
     Ensure that a default exception/code is used if invalid code is provided.
     """
     with self.assertRaises(CloudantClientException) as cm:
         raise CloudantClientException('foo')
     self.assertEqual(cm.exception.status_code, 100)
コード例 #4
0
 def test_raise_without_args(self):
     """
     Ensure that a default exception/code is used if the message requested
     by the code provided requires an argument list and none is provided.
     """
     with self.assertRaises(CloudantClientException) as cm:
         raise CloudantClientException(404)
     self.assertEqual(cm.exception.status_code, 100)
コード例 #5
0
 def create_database(self, dbname, throw_on_exists=False, remote=None):
     if remote is None:
         remote = self.remote
     new_db = self._DATABASE_CLASS(self, dbname, remote=remote)
     try:
         new_db.create(throw_on_exists)
     except CloudantDatabaseException as ex:
         if ex.status_code == 412:
             raise CloudantClientException(412, dbname)
     super(RemoteCouchDB, self).__setitem__(dbname, new_db)
     return new_db