예제 #1
0
    def test_from_binary_string_valid_input(self):
        resp = ErrorResponse()
        resp.from_binary_string(resp.to_binary_string(0, 123))

        self.assertEqual(resp.code, 0)
        self.assertEqual(resp.name, 'invalid token')
        self.assertEqual(resp.identifier, 123)
    def test_from_binary_string_valid_input(self):
        resp = ErrorResponse()
        resp.from_binary_string(resp.to_binary_string(0, 123))

        self.assertEqual(resp.code, 0)
        self.assertEqual(resp.name, 'invalid token')
        self.assertEqual(resp.identifier, 123)
    def test_properties_set(self, unpack_mock):
        unpack_mock.return_value = ErrorResponse.COMMAND, 0, 'identifier'
        resp = ErrorResponse()

        resp.from_binary_string('stream')

        self.assertEqual(resp.code, 0)
        self.assertEqual(resp.name, 'invalid token')
        self.assertEqual(resp.identifier, 'identifier')
예제 #4
0
    def test_properties_set(self, unpack_mock):
        unpack_mock.return_value = ErrorResponse.COMMAND, 0, 'identifier'
        resp = ErrorResponse()

        resp.from_binary_string('stream')

        self.assertEqual(resp.code, 0)
        self.assertEqual(resp.name, 'invalid token')
        self.assertEqual(resp.identifier, 'identifier')
예제 #5
0
 def dataReceived(self, data):
     error = ErrorResponse()
     error.from_binary_string(data)
     yield self.factory.errorReceived(error)
    def test_from_binary_string_invalid_code(self, unpack_mock):
        unpack_mock.return_value = ErrorResponse.COMMAND, 1, None
        resp = ErrorResponse()

        with self.assertRaises(ErrorResponseInvalidCodeError):
            resp.from_binary_string('stream')
    def test_str(self):
        resp = ErrorResponse()
        resp.name = 'name'

        self.assertEqual(str(resp), '<ErrorResponse: name>')
예제 #8
0
 def dataReceived(self, data):
     error = ErrorResponse()
     error.from_binary_string(data)
     yield self.factory.errorReceived(error)
예제 #9
0
    def test_from_binary_string_invalid_code(self, unpack_mock):
        unpack_mock.return_value = ErrorResponse.COMMAND, 1, None
        resp = ErrorResponse()

        with self.assertRaises(ErrorResponseInvalidCodeError):
            resp.from_binary_string('stream')
예제 #10
0
    def test_str(self):
        resp = ErrorResponse()
        resp.name = 'name'

        self.assertEqual(str(resp), '<ErrorResponse: name>')