Test encoding of a message into 'RecordIO' format.
()
| 25 | |
| 26 | |
| 27 | def test_encode(): |
| 28 | """ |
| 29 | Test encoding of a message into 'RecordIO' format. |
| 30 | """ |
| 31 | try: |
| 32 | encoder = recordio.Encoder(lambda s: bytes(json.dumps(s), "UTF-8")) |
| 33 | except Exception as exception: |
| 34 | raise MesosException("Error instantiating 'RecordIO' encoder: {error}" |
| 35 | .format(error=exception)) |
| 36 | |
| 37 | try: |
| 38 | message = { |
| 39 | "type": "ATTACH_CONTAINER_OUTPUT", |
| 40 | "containerId": "123456789" |
| 41 | } |
| 42 | |
| 43 | encoded = encoder.encode(message) |
| 44 | |
| 45 | except Exception as exception: |
| 46 | raise MesosException("Error encoding 'RecordIO' message: {error}" |
| 47 | .format(error=exception)) |
| 48 | |
| 49 | string = json.dumps(message) |
| 50 | assert encoded == bytes(str(len(string)) + "\n" + string, "UTF-8") |
| 51 | |
| 52 | |
| 53 | def test_encode_decode(): |
nothing calls this directly
no test coverage detected