def test_unicode(self): """ Ensure that unicode is handled correctly. """ s = status.Status(None, 'bar', 'baz') self.assertEqual(unicode(s), 'bar: baz')
def test_interface(self): """ Ensure that the correct interface is implemented. """ self.assertTrue(status.IStatus.implementedBy(status.Status)) s = status.Status(None, None, None) self.assertTrue(status.IStatus.providedBy(s))
def test_extra(self): """ Test L{Status.getExtraContext}. """ s = status.Status('foo', 'bar', 'baz', spam='eggs', extra='context') self.assertEqual(s.getExtraContext(), { 'spam': 'eggs', 'extra': 'context' })
def test_create(self): """ Test attribute allocation. """ s = status.Status('foo', 'bar', 'baz', spam='eggs') self.assertEqual(s.level, 'foo') self.assertEqual(s.code, 'bar') self.assertEqual(s.description, 'baz') self.assertEqual(s.spam, 'eggs')
def test_repr(self): """ Test for C{repr(status.Status)}. """ s = status.Status('foo', 'bar', 'baz', spam='eggs', extra='context') self.assertEqual( repr(s), ("<rtmpy.status.Status level='foo', " "code='bar', description='baz', extra={'spam': 'eggs', 'extra': " "'context'} at 0x%x>" % (id(s), )))
def test_equality(self): """ Its all in the name. """ s = status.Status('foo', 'bar', 'baz') # simple scalar checks self.assertNotEqual(s, 1) self.assertNotEqual(s, None) self.assertNotEqual(s, 'foo') ref_dict = {'level': 'foo', 'code': 'bar', 'description': 'baz'} self.assertEqual(s, ref_dict)
def test_amf3(self): """ Test encoding in AMF3. """ import pyamf ref_dict = { 'level': 'alevel', 'code': 'Some.Code.Here', 'description': 'Look mom, no hands!' } s = status.Status(ref_dict['level'], ref_dict['code'], ref_dict['description']) blob = pyamf.encode(s, encoding=pyamf.AMF3) decoded_status = pyamf.decode(blob, encoding=pyamf.AMF3).next() self.assertEqual(decoded_status, s)