MCPcopy Create free account
hub / github.com/apache/mesos / test_encode

Function test_encode

src/python/lib/tests/test_recordio.py:27–50  ·  view source on GitHub ↗

Test encoding of a message into 'RecordIO' format.

()

Source from the content-addressed store, hash-verified

25
26
27def 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
53def test_encode_decode():

Callers

nothing calls this directly

Calls 3

encodeMethod · 0.95
MesosExceptionClass · 0.90
EncoderMethod · 0.80

Tested by

no test coverage detected