Exemplo n.º 1
0
def test_qop_mod_6(monty_find, mongo_find):
    docs = [{"a": 8}]
    spec = {"a": {"$mod": [bson.Int64(4), 0]}}

    monty_c = monty_find(docs, spec)
    mongo_c = mongo_find(docs, spec)

    assert count_documents(mongo_c, spec) == 1
    assert count_documents(monty_c, spec) == count_documents(mongo_c, spec)
Exemplo n.º 2
0
def test_qop_mod_9(monty_find, mongo_find):
    docs = [{"a": 9}]
    spec = {"a": {"$mod": [4, bson.Int64("1")]}}

    monty_c = monty_find(docs, spec)
    mongo_c = mongo_find(docs, spec)

    assert count_documents(mongo_c, spec) == 1
    assert count_documents(monty_c, spec) == count_documents(mongo_c, spec)
Exemplo n.º 3
0
def test_update_mul_int64(monty_update, mongo_update):
    docs = [{"a": bson.Int64(2)}]
    spec = {"$mul": {"a": 1.5}}

    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": 3.0}
Exemplo n.º 4
0
def test_update_inc_int64(monty_update, mongo_update):
    docs = [{"a": bson.Int64(1)}]
    spec = {"$inc": {"a": 1.5}}

    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": 2.5}
def test_qop_ne_8(monty_find, mongo_find):
    docs = [
        {"a": 1},
    ]
    spec = {"a": {"$ne": bson.Int64(1)}}

    monty_c = monty_find(docs, spec)
    mongo_c = mongo_find(docs, spec)

    assert count_documents(mongo_c, spec) == 0
    assert count_documents(monty_c, spec) == count_documents(mongo_c, spec)
def test_qop_lte_20(monty_find, mongo_find):
    long_ = bson.Int64(10)
    int_ = 10
    float_ = 10.0
    decimal_ = bson.Decimal128("10.0")
    docs = [{"a": long_}, {"a": int_}, {"a": float_}, {"a": decimal_}]
    spec = {"a": {"$lte": 10.5}}

    monty_c = monty_find(docs, spec)
    mongo_c = mongo_find(docs, spec)

    assert count_documents(mongo_c, spec) == 4
    assert count_documents(monty_c, spec) == count_documents(mongo_c, spec)
    for i in range(4):
        assert next(mongo_c) == next(monty_c)
Exemplo n.º 7
0
def test_sort_5(monty_sort, mongo_sort):
    docs = [{
        "a": 0
    }, {
        "a": 1.1
    }, {
        "a": bson.Int64(2)
    }, {
        "a": bson.Decimal128("3.3")
    }]
    sort = [("a", -1)]

    monty_c = monty_sort(docs, sort)
    mongo_c = mongo_sort(docs, sort)

    for i in range(len(docs)):
        assert next(mongo_c)["_id"] == next(monty_c)["_id"]
Exemplo n.º 8
0
def test_weighted_4():
    data = bson.Int64(8)
    assert Weighted(data) == (2, data)