File: exceptions_test.py

package info (click to toggle)
python-pika 0.9.14-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,048 kB
  • ctags: 2,110
  • sloc: python: 10,046; makefile: 134
file content (39 lines) | stat: -rw-r--r-- 1,445 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Tests for pika.exceptions

"""
try:
    import unittest2 as unittest
except ImportError:
    import unittest

from pika import exceptions


class ExceptionTests(unittest.TestCase):

    def test_amqp_connection_error_one_param_repr(self):
        self.assertEqual(repr(exceptions.AMQPConnectionError(10)),
                         "No connection could be opened after 10 connection attempts")

    def test_amqp_connection_error_two_params_repr(self):
        self.assertEqual(repr(exceptions.AMQPConnectionError(1, 'Test')),
                         "1: Test")

    def test_authentication_error_repr(self):
        self.assertEqual(repr(exceptions.AuthenticationError('PLAIN')),
                         'Server and client could not negotiate use of the '
                         'PLAIN authentication mechanism')

    def test_body_too_long_error_repr(self):
        self.assertEqual(repr(exceptions.BodyTooLongError(100, 50)),
                         'Received too many bytes for a message delivery: '
                         'Received 100, expected 50' )

    def test_invalid_minimum_frame_size_repr(self):
        self.assertEqual(repr(exceptions.InvalidMinimumFrameSize()),
                         'AMQP Minimum Frame Size is 4096 Bytes')

    def test_invalid_maximum_frame_size_repr(self):
        self.assertEqual(repr(exceptions.InvalidMaximumFrameSize()),
                         'AMQP Maximum Frame Size is 131072 Bytes')