Example #1
0
    def test_validate_on_invalid_protocol_version_minor(self):
        major = ProtocolVersion.ProtocolVersionMajor(1)
        minor = "invalid"
        args = [major, minor]

        self.assertRaisesRegexp(TypeError, "invalid protocol version minor",
                                self._test_init, *args)
Example #2
0
    def _test_create(self, major, minor):
        protocol_version = ProtocolVersion.create(major, minor)

        if major is None:
            expected = ProtocolVersion.ProtocolVersionMajor()
        else:
            expected = ProtocolVersion.ProtocolVersionMajor(major)

        self.assertEqual(expected, protocol_version.protocol_version_major)

        if minor is None:
            expected = ProtocolVersion.ProtocolVersionMinor()
        else:
            expected = ProtocolVersion.ProtocolVersionMinor(minor)

        self.assertEqual(expected, protocol_version.protocol_version_minor)
Example #3
0
    def setUp(self):
        super(TestProtocolVersion, self).setUp()

        self.major_default = ProtocolVersion.ProtocolVersionMajor()
        self.minor_default = ProtocolVersion.ProtocolVersionMinor()
        self.major = ProtocolVersion.ProtocolVersionMajor(1)
        self.minor = ProtocolVersion.ProtocolVersionMinor(1)

        self.encoding_default = BytearrayStream((
            b'\x42\x00\x69\x01\x00\x00\x00\x20\x42\x00\x6A\x02\x00\x00\x00\x04'
            b'\x00\x00\x00\x00\x00\x00\x00\x00\x42\x00\x6B\x02\x00\x00\x00\x04'
            b'\x00\x00\x00\x00\x00\x00\x00\x00'))
        self.encoding = BytearrayStream((
            b'\x42\x00\x69\x01\x00\x00\x00\x20\x42\x00\x6A\x02\x00\x00\x00\x04'
            b'\x00\x00\x00\x01\x00\x00\x00\x00\x42\x00\x6B\x02\x00\x00\x00\x04'
            b'\x00\x00\x00\x01\x00\x00\x00\x00'))
Example #4
0
    def _test_init(self, protocol_version_major, protocol_version_minor):
        protocol_version = ProtocolVersion(protocol_version_major,
                                           protocol_version_minor)

        if protocol_version_major is None:
            self.assertEqual(ProtocolVersion.ProtocolVersionMajor(),
                             protocol_version.protocol_version_major)
        else:
            self.assertEqual(protocol_version_major,
                             protocol_version.protocol_version_major)

        if protocol_version_minor is None:
            self.assertEqual(ProtocolVersion.ProtocolVersionMinor(),
                             protocol_version.protocol_version_minor)
        else:
            self.assertEqual(protocol_version_minor,
                             protocol_version.protocol_version_minor)
Example #5
0
    def test_init_with_args(self):
        major = ProtocolVersion.ProtocolVersionMajor(1)
        minor = ProtocolVersion.ProtocolVersionMinor(0)

        self._test_init(major, minor)