Example #1
0
 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())
Example #2
0
 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())
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 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 = {}
Example #8
0
 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 = {}
Example #9
0
 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"))
Example #10
0
 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"))
Example #11
0
 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'))
Example #12
0
 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
Example #13
0
 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"))
Example #14
0
 def setUp(self):
     """
     Create default constructed object
     """
     self.message = LofarMessage()