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"
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"
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"
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"
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"