MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_basic_decode

Method test_basic_decode

test/test_bson.py:281–322  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

279 )
280
281 def test_basic_decode(self):
282 self.assertEqual(
283 {"test": "hello world"},
284 decode(
285 b"\x1B\x00\x00\x00\x0E\x74\x65\x73\x74\x00\x0C"
286 b"\x00\x00\x00\x68\x65\x6C\x6C\x6F\x20\x77\x6F"
287 b"\x72\x6C\x64\x00\x00"
288 ),
289 )
290 self.assertEqual(
291 [{"test": "hello world"}, {}],
292 decode_all(
293 b"\x1B\x00\x00\x00\x0E\x74\x65\x73\x74"
294 b"\x00\x0C\x00\x00\x00\x68\x65\x6C\x6C"
295 b"\x6f\x20\x77\x6F\x72\x6C\x64\x00\x00"
296 b"\x05\x00\x00\x00\x00"
297 ),
298 )
299 self.assertEqual(
300 [{"test": "hello world"}, {}],
301 list(
302 decode_iter(
303 b"\x1B\x00\x00\x00\x0E\x74\x65\x73\x74"
304 b"\x00\x0C\x00\x00\x00\x68\x65\x6C\x6C"
305 b"\x6f\x20\x77\x6F\x72\x6C\x64\x00\x00"
306 b"\x05\x00\x00\x00\x00"
307 )
308 ),
309 )
310 self.assertEqual(
311 [{"test": "hello world"}, {}],
312 list(
313 decode_file_iter(
314 BytesIO(
315 b"\x1B\x00\x00\x00\x0E\x74\x65\x73\x74"
316 b"\x00\x0C\x00\x00\x00\x68\x65\x6C\x6C"
317 b"\x6f\x20\x77\x6F\x72\x6C\x64\x00\x00"
318 b"\x05\x00\x00\x00\x00"
319 )
320 )
321 ),
322 )
323
324 def test_decode_all_buffer_protocol(self):
325 docs = [{"foo": "bar"}, {}]

Callers

nothing calls this directly

Calls 4

decodeFunction · 0.90
decode_allFunction · 0.90
decode_iterFunction · 0.90
decode_file_iterFunction · 0.90

Tested by

no test coverage detected