def update_runs():
    for plan in plans:
        runs = proxy.TestPlan.get_test_runs(plan)
        for run in runs:
            run["name"] = "runs"
            run_id = run.get("run_id")
            mongo_tt.update_one({"name": "runs", "run_id": run_id}, {"$set": run}, upsert=True)
def update_testcase_bugs():
    # only to query cases that are failed or blocked to save server force
    cases = mongo_tt.find({"name": "case_run", "case_run_status_id": {"$in": [3, 4, 5, 6]}}, {"case_id": 1})
    caseids = [i["case_id"] for i in cases]
    caseids = set(caseids)  # avoid duplicate cases
    for case in caseids:
        print(case)
        bugs = proxy.TestCase.get_bugs(case)
        for bug in bugs:
            # I found a situation that a bug binded with a test case bug have no
            # run. I don't know why. So escape it
            if "case_run_id" not in bug:
                continue
            bug["name"] = "bugs"
            bug["case_id"] = case
            mongo_tt.update_one({"name": "bugs", "case_run_id": bug["case_run_id"]}, {"$set": bug}, upsert=True)
def update_case_runs():
    runs = mongo_tt.find({"name": "runs"}, {"run_id": 1, "_id": 0})
    runids = [r["run_id"] for r in runs]
    print(runids)
    for runid in runids:
        case_runs = proxy.TestRun.get_test_case_runs(runid)
        for case_run in case_runs:
            case_run["name"] = "case_run"
            mongo_tt.update_one(
                {"name": "case_run", "case_run_id": case_run["case_run_id"]}, {"$set": case_run}, upsert=True
            )

    for runid in runids:
        cases = proxy.TestRun.get_test_cases(runid)
        for case in cases:
            # use update_many, since a case may have many case_run
            mongo_tt.update_many({"name": "case_run", "case_id": case["case_id"]}, {"$set": case}, upsert=True)
Example #4
0
 def get(self, runid):
     try:
         mongo_tt.update_one({"name": "runs", "run_id": int(runid)}, {"$set": {"expire": 1}})
     except:
         pass
Example #5
0
 def get(self, runid):
     try:
         mongo_tt.update_one({'name':'runs', 'run_id': int(runid)},
                 {'$set': {'expire':1}})
     except:
         pass