MCPcopy Index your code
hub / github.com/saltstack/salt / test_map_size

Function test_map_size

tests/pytests/unit/utils/test_msgpack.py:182–198  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180
181
182def test_map_size():
183 sizes = [0, 5, 50, 1000]
184 bio = io.BytesIO()
185 packer = salt.utils.msgpack.Packer()
186 for size in sizes:
187 bio.write(packer.pack_map_header(size))
188 for i in range(size):
189 bio.write(packer.pack(i)) # key
190 bio.write(packer.pack(i * 2)) # value
191
192 bio.seek(0)
193 if salt.utils.msgpack.version > (0, 6, 0):
194 unpacker = salt.utils.msgpack.Unpacker(bio, strict_map_key=False)
195 else:
196 unpacker = salt.utils.msgpack.Unpacker(bio)
197 for size in sizes:
198 assert unpacker.unpack() == {i: i * 2 for i in range(size)}
199
200
201def test_max_buffer_size():

Callers

nothing calls this directly

Calls 3

unpackMethod · 0.80
writeMethod · 0.45
packMethod · 0.45

Tested by

no test coverage detected