def check_result(self, resp, expect, ignore_col: Set[int] = set(), is_regex=False): if resp.is_empty() and len(expect) == 0: return assert not resp.is_empty(), 'resp.data is None' rows = resp.rows() assert len(rows) == len(expect), f'{len(rows)}!={len(expect)}' new_expect = expect if not is_regex: # convert expect to thrift value new_expect = self.convert_expect(expect) for row, i in zip(rows, range(0, len(new_expect))): columns = new_expect[i].values if isinstance( new_expect[i], CommonTtypes.Row) else new_expect[i] assert len(row.values) - len(ignore_col) == len(columns) ignored_col_count = 0 for j, col in enumerate(row.values): if j in ignore_col: ignored_col_count += 1 continue exp_val = columns[j - ignored_col_count] expect_to_string = row_to_string(columns) assert compare_value(col, exp_val), \ 'The returned row from nebula could not be found, row: {}, expect: {}'.format( row_to_string(row), expect_to_string)
def search(self, resp, expect, is_regex=False, exist=True): if resp.is_empty() and len(expect) == 0: return assert not resp.is_empty(), 'resp.data is None' rows = resp.rows() assert len(rows) >= len(expect), f'{len(rows)} < {len(expect)}' new_expect = expect if not is_regex: # convert expect to thrift value new_expect = self.convert_expect(expect) msg = 'Returned row from nebula could not be found, row: {}, resp: {}' for exp in new_expect: values, exp_str = (exp, str(exp)) if is_regex else (exp.values, row_to_string(exp)) assert find_in_rows(values, rows) == exist, \ msg.format(exp_str, value_to_string(rows))