Skip to content

Commit

Permalink
Decimal128 support
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
ajdavis committed Feb 24, 2018
1 parent 27f29b0 commit 3ea04af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions mockupdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ def marker(obj):
13: lambda obj: (obj.scope, str(obj)),
# Timestamp.
17: lambda obj: (obj.time, obj.inc),
# Decimal128.
19: lambda obj: obj.bid,
# DBRef.
100: lambda obj: (obj.database, obj.collection, obj.id),
# MaxKey.
Expand Down
11 changes: 6 additions & 5 deletions tests/test_mockupdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from Queue import Queue

# Tests depend on PyMongo's BSON implementation, but MockupDB itself does not.
from bson import (SON, ObjectId, Binary, Regex, Code, Timestamp, DBRef,
MaxKey, MinKey)
from bson import (Binary, Code, DBRef, Decimal128, MaxKey, MinKey, ObjectId,
Regex, SON, Timestamp)
from bson.codec_options import CodecOptions
from pymongo import MongoClient, message, WriteConcern

Expand Down Expand Up @@ -200,15 +200,16 @@ def test_bson_classes(self):

for a, b in [
(Binary(b'foo'), mockup_bson.Binary(b'foo')),
(ObjectId(_id), mockup_bson.ObjectId(_id)),
(Regex('foo', 'i'), mockup_bson.Regex('foo', 'i')),
(Code('foo'), mockup_bson.Code('foo')),
(Code('foo', {'x': 1}), mockup_bson.Code('foo', {'x': 1})),
(Timestamp(1, 2), mockup_bson.Timestamp(1, 2)),
(DBRef('coll', 1), mockup_bson.DBRef('coll', 1)),
(DBRef('coll', 1, 'db'), mockup_bson.DBRef('coll', 1, 'db')),
(Decimal128('1'), mockup_bson.Decimal128('1')),
(MaxKey(), mockup_bson.MaxKey()),
(MinKey(), mockup_bson.MinKey()),
(ObjectId(_id), mockup_bson.ObjectId(_id)),
(Regex('foo', 'i'), mockup_bson.Regex('foo', 'i')),
(Timestamp(1, 2), mockup_bson.Timestamp(1, 2)),
]:
# Basic case.
self.assertTrue(
Expand Down

0 comments on commit 3ea04af

Please sign in to comment.