Ejemplo n.º 1
0
def test_get_runs_order(db_gateway: PyMongoDataAccess):
    runs = list(db_gateway.get_runs(sort_by="host.python_version"))
    assert len(runs) == 2
    assert runs[0]["host"]["python_version"] == "3.4.3"
    assert runs[1]["host"]["python_version"] == "3.5.2"

    runs = list(
        db_gateway.get_runs(sort_by="host.python_version",
                            sort_direction="desc"))
    assert len(runs) == 2
    assert runs[0]["host"]["python_version"] == "3.5.2"
    assert runs[1]["host"]["python_version"] == "3.4.3"
Ejemplo n.º 2
0
def test_get_runs_filter_or(db_gateway: PyMongoDataAccess):
    filter = {
        "type":
        "and",
        "filters": [{
            "field": "host.hostname",
            "operator": "==",
            "value": "ntbacer"
        }, {
            "type":
            "or",
            "filters": [{
                "field": "result",
                "operator": "==",
                "value": 2403.52
            }, {
                "field": "host.python_version",
                "operator": "==",
                "value": "3.5.2"
            }]
        }]
    }
    runs = list(db_gateway.get_runs(query=filter))
    assert len(runs) == 1
    assert runs[0]["host"]["hostname"] == "ntbacer"
    assert runs[0]["result"] == 2403.52

    filter = {
        "type":
        "and",
        "filters": [{
            "field": "host.hostname",
            "operator": "==",
            "value": "martin-virtual-machine"
        }, {
            "type":
            "or",
            "filters": [{
                "field": "result",
                "operator": "==",
                "value": 2403.52
            }, {
                "field": "host.python_version",
                "operator": "==",
                "value": "3.5.2"
            }]
        }]
    }
    runs = list(db_gateway.get_runs(query=filter))
    assert len(runs) == 1
    assert runs[0]["host"]["hostname"] == "martin-virtual-machine"
    assert runs[0]["host"]["python_version"] == "3.5.2"

    filter = {
        "type":
        "and",
        "filters": [{
            "type":
            "or",
            "filters": [{
                "field": "result",
                "operator": "==",
                "value": 2403.52
            }, {
                "field": "host.python_version",
                "operator": "==",
                "value": "3.5.2"
            }]
        }]
    }
    runs = list(db_gateway.get_runs(query=filter))
    assert len(runs) == 2

    assert runs[0]["host"]["hostname"] == "ntbacer"
    assert runs[0]["host"]["python_version"] == "3.4.3"

    assert runs[1]["host"]["hostname"] == "martin-virtual-machine"
    assert runs[1]["host"]["python_version"] == "3.5.2"
Ejemplo n.º 3
0
def test_get_runs_filter(db_gateway: PyMongoDataAccess, query_filter):
    runs = list(db_gateway.get_runs(query=query_filter))
    assert len(runs) == 1
    assert runs[0]["host"]["hostname"] == "ntbacer"
Ejemplo n.º 4
0
def test_get_runs_limit(db_gateway: PyMongoDataAccess):
    runs = list(db_gateway.get_runs(limit=1))
    assert len(runs) == 1
    assert runs[0]["host"]["hostname"] == "ntbacer"
Ejemplo n.º 5
0
def test_get_runs(db_gateway: PyMongoDataAccess):
    runs = list(db_gateway.get_runs())
    assert len(runs) == 2
    assert runs[0]["host"]["hostname"] == "ntbacer"
    assert runs[1]["host"]["hostname"] == "martin-virtual-machine"