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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
import unittest
from pika import amqp_object
class AMQPObjectTests(unittest.TestCase):
def test_base_name(self):
self.assertEqual(amqp_object.AMQPObject().NAME, 'AMQPObject')
def test_repr_no_items(self):
obj = amqp_object.AMQPObject()
self.assertEqual(repr(obj), '<AMQPObject>')
def test_repr_items(self):
obj = amqp_object.AMQPObject()
setattr(obj, 'foo', 'bar')
setattr(obj, 'baz', 'qux')
self.assertEqual(repr(obj), "<AMQPObject(['baz=qux', 'foo=bar'])>")
def test_equality(self):
a = amqp_object.AMQPObject()
b = amqp_object.AMQPObject()
self.assertEqual(a, b)
setattr(a, "a_property", "test")
self.assertNotEqual(a, b)
setattr(b, "a_property", "test")
self.assertEqual(a, b)
class ClassTests(unittest.TestCase):
def test_base_name(self):
self.assertEqual(amqp_object.Class().NAME, 'Unextended Class')
def test_equality(self):
a = amqp_object.Class()
b = amqp_object.Class()
self.assertEqual(a, b)
class MethodTests(unittest.TestCase):
def test_base_name(self):
self.assertEqual(amqp_object.Method().NAME, 'Unextended Method')
def test_set_content_body(self):
properties = amqp_object.Properties()
body = 'This is a test'
obj = amqp_object.Method()
obj._set_content(properties, body)
self.assertEqual(obj._body, body)
def test_set_content_properties(self):
properties = amqp_object.Properties()
body = 'This is a test'
obj = amqp_object.Method()
obj._set_content(properties, body)
self.assertEqual(obj._properties, properties)
def test_get_body(self):
properties = amqp_object.Properties()
body = 'This is a test'
obj = amqp_object.Method()
obj._set_content(properties, body)
self.assertEqual(obj.get_body(), body)
def test_get_properties(self):
properties = amqp_object.Properties()
body = 'This is a test'
obj = amqp_object.Method()
obj._set_content(properties, body)
self.assertEqual(obj.get_properties(), properties)
class PropertiesTests(unittest.TestCase):
def test_base_name(self):
self.assertEqual(amqp_object.Properties().NAME,
'Unextended Properties')
|