|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +import io |
15 | 16 | import unittest |
16 | 17 |
|
17 | 18 | from unittest.mock import Mock |
18 | 19 |
|
19 | | -from cassandra import ProtocolVersion, UnsupportedOperation |
| 20 | +from cassandra import DriverException, ProtocolVersion, UnsupportedOperation, type_codes |
20 | 21 | from cassandra.protocol import ( |
21 | | - PrepareMessage, QueryMessage, ExecuteMessage, UnsupportedOperation, |
| 22 | + PrepareMessage, QueryMessage, ExecuteMessage, ResultMessage, UnsupportedOperation, |
22 | 23 | _PAGING_OPTIONS_FLAG, _WITH_SERIAL_CONSISTENCY_FLAG, |
23 | 24 | _PAGE_SIZE_FLAG, _WITH_PAGING_STATE_FLAG, |
24 | | - BatchMessage |
| 25 | + BatchMessage, RESULT_KIND_ROWS, write_int, write_short, write_string |
25 | 26 | ) |
26 | 27 | from cassandra.query import BatchType |
27 | 28 | from cassandra.marshal import uint32_unpack |
|
31 | 32 |
|
32 | 33 | class MessageTest(unittest.TestCase): |
33 | 34 |
|
| 35 | + def test_result_message_wraps_inline_decode_errors(self): |
| 36 | + body = io.BytesIO() |
| 37 | + write_int(body, RESULT_KIND_ROWS) |
| 38 | + write_int(body, 0) |
| 39 | + write_int(body, 1) |
| 40 | + write_string(body, "ks") |
| 41 | + write_string(body, "tbl") |
| 42 | + write_string(body, "v") |
| 43 | + write_short(body, type_codes.DateType) |
| 44 | + write_int(body, 1) |
| 45 | + write_int(body, 1) |
| 46 | + body.write(b"\x00") |
| 47 | + |
| 48 | + with pytest.raises(DriverException, match='Failed decoding result column "v"'): |
| 49 | + ResultMessage.recv_body(io.BytesIO(body.getvalue()), ProtocolVersion.V4, 0, {}, None, None) |
| 50 | + |
34 | 51 | def test_prepare_message(self): |
35 | 52 | """ |
36 | 53 | Test to check the appropriate calls are made |
|
0 commit comments