예제 #1
0
    def test_unicode(self):
        """
        Ensure that unicode is handled correctly.
        """
        s = status.Status(None, 'bar', 'baz')

        self.assertEqual(unicode(s), 'bar: baz')
예제 #2
0
    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))
예제 #3
0
    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'
        })
예제 #4
0
    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')
예제 #5
0
    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), )))
예제 #6
0
    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)
예제 #7
0
    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)