def test_propname_not_contains_properties(self): """ Test that prop_names() does not return the property 'properties'. This attribute should not be visible. """ msg = LofarMessage(self.qmsg) self.assertNotIn('properties', msg.prop_names())
def test_setattr_qpid_property(self): """ Test that an LofarMessage attribute becomes a Qpid message property. """ msg = LofarMessage(self.qmsg) msg.NewProperty = "New Property" self.assertEqual(msg.qpid_msg.properties["NewProperty"], msg.NewProperty)
def test_setattr_qpid_field(self): """ Test that an LofarMessage attribute becomes a Qpid message field. """ msg = LofarMessage(self.qmsg) msg.ttl = 100 self.assertEqual(self.qmsg.ttl, msg.ttl) self.assertEqual(self.qmsg.ttl, 100)
def test_setattr_raises_on_properties(self): """ Test that exception is raised if attribute 'properties' is written. This attribute should not be visible. """ msg = LofarMessage(self.qmsg) with self.assertRaisesRegexp(AttributeError, "object has no attribute"): msg.properties = {}
def test_construct_from_dict(self): """ Test that an LofarMessage can be constructed from a python dict. """ content = {1: 'one', 2: 'two', 3: 'three'} msg = LofarMessage(content) self.assertEqual((msg.content, msg.content_type), (content, "amqp/map"))
def test_construct_from_list(self): """ Test that an LofarMessage can be constructed from a python list. """ content = range(10) msg = LofarMessage(content) self.assertEqual((msg.content, msg.content_type), (content, "amqp/list"))
def test_construct_from_string(self): """ Test that an LofarMessage can be constructed from an ASCII string. """ content = "ASCII string" msg = LofarMessage(content) self.assertEqual((msg.content, msg.content_type), (unicode(content), 'text/plain'))
def test_getattr_raises(self): """ Test that exception is raised if a non-existent attribute is read. """ msg = LofarMessage(self.qmsg) with self.assertRaisesRegexp(AttributeError, "object has no attribute"): _ = msg.non_existent
def test_construct_from_unicode(self): """ Test that an LofarMessage can be constructed from a Unicode string. :return: """ content = u"Unicode string" msg = LofarMessage(content) self.assertEqual((msg.content, msg.content_type), (content, "text/plain"))
def setUp(self): """ Create default constructed object """ self.message = LofarMessage()