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

Method test_numberlong

test/test_json_util.py:565–577  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

563 self.assertIsNone(json_util.loads(jsn)["name"])
564
565 def test_numberlong(self):
566 jsn = '{"weight": {"$numberLong": "65535"}}'
567 self.assertEqual(json_util.loads(jsn)["weight"], Int64(65535))
568 self.assertEqual(json_util.dumps({"weight": Int64(65535)}), '{"weight": 65535}')
569 json_options = JSONOptions(strict_number_long=True, json_mode=JSONMode.LEGACY)
570 self.assertEqual(json_util.dumps({"weight": Int64(65535)}, json_options=json_options), jsn)
571 # Ensure json_util.default converts Int64 to int in non-strict mode.
572 converted = json_util.default(Int64(65535))
573 self.assertEqual(converted, 65535)
574 self.assertNotIsInstance(converted, Int64)
575 self.assertEqual(
576 json_util.default(Int64(65535), json_options=json_options), {"$numberLong": "65535"}
577 )
578
579 def test_loads_document_class(self):
580 json_doc = '{"foo": "bar", "b": 1, "d": {"a": 1}}'

Callers

nothing calls this directly

Calls 2

Int64Class · 0.90
JSONOptionsClass · 0.90

Tested by

no test coverage detected