def run_checks(condition_result): rdb = get_test_db() for ct, expected in condition_result: t = RTCheck.from_string(ct) res = t.check(rdb) if not res.status == expected: raise_error(rdb, t, res, f"Expected {expected}")
def parse_list_of_checks(checks): checks = copy.deepcopy(checks) cwcs = [] for c in checks: desc = c.pop('desc', None) cond = c.pop('cond') if c: msg = 'Spurious fields: %s' % list(c) raise ValueError(msg) lines = [_.strip() for _ in cond.strip().split('\n') if _.strip()] # remove comments decommented = [] for l in lines: if '#' in l: l = l[:l.index('#')] if l.strip(): decommented.append(l) cwc_checks = [RTCheck.from_string(_) for _ in decommented] cwc = ChecksWithComment(checks=cwc_checks, comment=desc) cwcs.append(cwc) return cwcs
def parse_list_of_checks( checks: List[CheckDescription]) -> List[ChecksWithComment]: checks = copy.deepcopy(checks) cwcs = [] for c in checks: c2 = dict(c) desc = c2.pop("desc", None) cond = c2.pop("cond") if c2: msg = f"Spurious fields: {list(c)}" raise ValueError(msg) lines = [_.strip() for _ in cond.strip().split("\n") if _.strip()] # remove comments decommented = [] for l in lines: if "#" in l: l = l[:l.index("#")] if l.strip(): decommented.append(l) cwc_checks = [RTCheck.from_string(_) for _ in decommented] cwc = ChecksWithComment(checks=cwc_checks, comment=desc) cwcs.append(cwc) return cwcs