-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3263700
commit b502a50
Showing
4 changed files
with
202 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
from datetime import datetime | ||
from bson.timestamp import Timestamp | ||
from bson.max_key import MaxKey | ||
|
||
|
||
def test_update_max_1(monty_update, mongo_update): | ||
docs = [ | ||
{"a": 1} | ||
] | ||
spec = {"$max": {"a": 10}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": 10} | ||
|
||
|
||
def test_update_max_2(monty_update, mongo_update): | ||
docs = [ | ||
{"a": 1} | ||
] | ||
spec = {"$max": {"a": True}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": 1} | ||
|
||
|
||
def test_update_max_3(monty_update, mongo_update): | ||
docs = [ | ||
{"a": None} | ||
] | ||
spec = {"$max": {"a": True}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": True} | ||
|
||
|
||
def test_update_max_4(monty_update, mongo_update): | ||
docs = [ | ||
{"a": {"b": 5}} | ||
] | ||
spec = {"$max": {"a": MaxKey()}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": MaxKey()} | ||
|
||
|
||
def test_update_max_5(monty_update, mongo_update): | ||
docs = [ | ||
{"a": datetime(1998, 8, 22)} | ||
] | ||
spec = {"$max": {"a": datetime(1000, 8, 22)}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": datetime(1998, 8, 22)} | ||
|
||
|
||
def test_update_max_6(monty_update, mongo_update): | ||
docs = [ | ||
{"a": Timestamp(10, 5)} | ||
] | ||
spec = {"$max": {"a": Timestamp(10, 10)}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": Timestamp(10, 10)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
from datetime import datetime | ||
from bson.timestamp import Timestamp | ||
from bson.max_key import MaxKey | ||
|
||
|
||
def test_update_min_1(monty_update, mongo_update): | ||
docs = [ | ||
{"a": 1} | ||
] | ||
spec = {"$min": {"a": 0}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": 0} | ||
|
||
|
||
def test_update_min_2(monty_update, mongo_update): | ||
docs = [ | ||
{"a": 1} | ||
] | ||
spec = {"$min": {"a": True}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": True} | ||
|
||
|
||
def test_update_min_3(monty_update, mongo_update): | ||
docs = [ | ||
{"a": {"b": 5}, "0": None} | ||
] | ||
spec = {"$min": {"a": {"b": 3}}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": {"b": 3}, "0": None} | ||
|
||
|
||
def test_update_min_4(monty_update, mongo_update): | ||
docs = [ | ||
{"a": {"b": 5}} | ||
] | ||
spec = {"$min": {"a": MaxKey()}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": {"b": 5}} | ||
|
||
|
||
def test_update_min_5(monty_update, mongo_update): | ||
docs = [ | ||
{"a": datetime(1998, 8, 22)} | ||
] | ||
spec = {"$min": {"a": datetime(1000, 8, 22)}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": datetime(1000, 8, 22)} | ||
|
||
|
||
def test_update_min_6(monty_update, mongo_update): | ||
docs = [ | ||
{"a": Timestamp(10, 5)} | ||
] | ||
spec = {"$min": {"a": Timestamp(10, 0)}} | ||
|
||
monty_c = monty_update(docs, spec) | ||
mongo_c = mongo_update(docs, spec) | ||
|
||
assert next(mongo_c) == next(monty_c) | ||
monty_c.rewind() | ||
assert next(monty_c) == {"a": Timestamp(10, 0)} |