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')
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>')