Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1241

BSON Corpus Test doesn't thoroughly test JSON generation

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Tests
    • None

      Here:

      https://github.com/mongodb/specifications/blob/master/source/bson-corpus/bson-corpus.rst#testing-validity

      It specifies the test should do:

              assert encode_extjson(decode_bson(B)) == cE             # B->cE
              assert encode_extjson(decode_extjson(E)) == cE          # E->cE
      

      But in test_bson_corpus.py:

      self.assertEqual(
          json.loads(encode_extjson(decode_bson(B))),
          normalized_cE)
      
      self.assertEqual(
          json.loads(encode_extjson(decode_extjson(E))),
          normalized_cE)
      

      This isn't quite right. The Python test thoroughly tests parsing but not generation. E.g. it doesn't prove that all ints are generated as $numberInt or $numberLong, the test can pass even with bare ints like "1", which are not up to spec.

            Assignee:
            luke.lovett Luke Lovett
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: