Skip to content

Commit a83f1d6

Browse files
committed
Add bson only test_bad_dbref.
1 parent 3114b66 commit a83f1d6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

test/test_bson.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ def encode_then_decode(doc):
207207
qcheck.check_unittest(self, encode_then_decode,
208208
qcheck.gen_mongo_dict(3))
209209

210+
def test_bad_dbref(self):
211+
ref_only = {'ref': {'$ref': 'collection'}}
212+
id_only = {'ref': {'$id': ObjectId()}}
213+
214+
self.assertEqual(DBRef('collection', id=None),
215+
BSON.encode(ref_only).decode()['ref'])
216+
self.assertEqual(id_only, BSON.encode(id_only).decode())
217+
210218
def test_bytes_as_keys(self):
211219
doc = {b("foo"): 'bar'}
212220
# Since `bytes` are stored as Binary you can't use them

0 commit comments

Comments
 (0)