Skip to content

Commit

Permalink
Merge branch 'hotfix/0.15.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Sep 20, 2012
2 parents 1e639e5 + 04525ec commit a3478ab
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
2 changes: 1 addition & 1 deletion eulexistdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"""

__version_info__ = (0, 15, 2, None)
__version_info__ = (0, 15, 3, None)

# Dot-connect all but the last. Last is dash-connected if not None.
__version__ = '.'.join([ str(i) for i in __version_info__[:-1] ])
Expand Down
3 changes: 2 additions & 1 deletion eulexistdb/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import socket
import xmlrpclib
from urllib import unquote_plus

class ExistDBException(Exception):
"""A handy wrapper for all errors returned by the eXist server."""
Expand Down Expand Up @@ -47,7 +48,7 @@ def message(self):
message = message.replace('[at line 1, column 1]', '')
else:
# if all else fails, display the exception as a string
message = str(original_exception)
message = str(orig_except)
return message


Expand Down
1 change: 1 addition & 0 deletions test/test_existdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
from test_existdb.test_query import *
from test_existdb.test_models import *
from test_existdb.test_templatetags import *
from test_existdb.test_exceptions import *
56 changes: 56 additions & 0 deletions test/test_existdb/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python

# file test_existdb/test_exceptions.py
#
# Copyright 2012 Emory University Libraries
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import socket
import unittest
import xmlrpclib

from eulexistdb.exceptions import ExistDBException
from testcore import main

class ExistDbExceptionTest(unittest.TestCase):

def test_message(self):
# generic exception

msg_text = 'this is a basic exception message'
err = ExistDBException(Exception(msg_text))
self.assertEqual(msg_text, err.message())

# socket timeout
err = ExistDBException(socket.timeout())
self.assertEqual('Request Timed Out', err.message())

# xmlrpc error
# - args are url, error code, error message, headers
rpc_err = xmlrpclib.ProtocolError('http://so.me/url', 101,
'rpc error message', {})
err = ExistDBException(rpc_err)
# message should contain various bits of info from exception
msg = err.message()
self.assert_('XMLRPC Error' in msg)
self.assert_(rpc_err.url in msg)
self.assert_(str(rpc_err.errcode) in msg)
self.assert_(rpc_err.errmsg in msg)

# no test for exist-speficic errors (need an exaample error)



if __name__ == '__main__':
main()

0 comments on commit a3478ab

Please sign in to comment.