~tribaal/txaws/xss-hardening

« back to all changes in this revision

Viewing changes to txaws/server/tests/test_exception.py

  • Committer: Alberto Donato
  • Date: 2011-12-01 14:19:12 UTC
  • mto: This revision was merged to the branch mainline in revision 104.
  • Revision ID: alberto.donato@canonical.com-20111201141912-54pen2eyv2o1q23a
Return paramters values as utf8 in errors, if possible.
Convert APIError message to string to avoid problems with twisted logger.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
1
3
from unittest import TestCase
2
4
 
3
5
from txaws.server.exception import APIError
49
51
        """
50
52
        error = APIError("200", response="noes")
51
53
        self.assertEqual(200, error.status)
 
54
 
 
55
    def test_with_unicode_message(self):
 
56
        """
 
57
        L{APIError} will convert message to plain ASCII if converted to string. 
 
58
        """
 
59
        error = APIError(400, code="APIError", message=u"cittá")
 
60
        self.assertEqual(u"cittá", error.message)
 
61
        self.assertEqual("citt?", str(error))