Beispiel #1
0
def test_update_many_error_db():
    """test_update_many_error_db"""
    mongo_db_access = MongoDBAccess(CONFIG_ERROR, "DEBUG")
    res = mongo_db_access.update_many("testUpdateManyErrorDB", {"clave": "IP"},
                                      {'valorX': "1234"})

    assert res is None
Beispiel #2
0
def test_update_many_ok():
    """test_update_many_ok"""
    mongo_db_access = MongoDBAccess(CONFIG, "DEBUG")

    mongo_db_access.insert("testUpdateMany_ok", {
        "clave": "IPUpdateMany",
        "value": 0
    })
    mongo_db_access.insert("testUpdateMany_ok", {
        "clave": "IPUpdateMany",
        "value": 0
    })

    res_update = mongo_db_access.update_many("testUpdateMany_ok",\
                                                {"clave":"IPUpdateMany"}, {'value':1})
    res_find = mongo_db_access.find("testUpdateMany_ok",
                                    {"clave": "IPUpdateMany"})
    count_elements = 0
    for element_finding in res_find:
        count_elements += 1
        assert element_finding['value'] == 1

    assert res_update.modified_count == 2
    mongo_db_access.drop("testUpdateMany_ok")
    assert count_elements == 2
Beispiel #3
0
def test_update_many_error_find():
    """test_update_many_error_find"""
    mongo_db_access = MongoDBAccess(CONFIG, "DEBUG")
    mongo_db_access.insert("testUpdateManyErrorFind",\
                                         {"clave":"IPUpdateManyErrorF", "value":0})
    res = mongo_db_access.update_many("testUpdateManyErrorFind",\
                                      {"clave":"IPUpdateManyErrorFXX"}, {'value':1})
    mongo_db_access.drop("testUpdateManyErrorFind")

    assert res.modified_count == 0
Beispiel #4
0
def test_update_many_error_collect():
    """test_update_many_error_collection"""
    mongo_db_access = MongoDBAccess(CONFIG, "DEBUG")
    mongo_db_access.insert("testUpdateManyErrorColection",\
                                         {"clave":"IPUpdateMany", "value":0})
    mongo_db_access.insert("testUpdateManyErrorColection",\
                                        {"clave":"IPUpdateMany", "value":0})
    res = mongo_db_access.update_many("testUpdateManyErrorColectionXX",\
                                      {"clave":"IPManyUpdateError"}, {'valorX':"1234"})
    mongo_db_access.drop("testUpdateManyErrorColection")

    assert res.modified_count == 0