示例#1
0
def test_get_all_chart_data():
    global test_db_file
    filename = os.path.join(os.getcwd(), test_db_file)
    query1 = 'Select TotalFrameCount from AnalyzerPortResults'
    data = sql_utils.get_all_chart_data(query1, "SINGLE", [filename])
    assert data is not None
    assert data == [1151261, 1239945]

    query3 = 'Select TotalFrameCount, TotalOctetCount from AnalyzerPortResults'
    data = sql_utils.get_all_chart_data(query3, "PAIR", [filename])
    assert data is not None
    assert data == [[1151261, 147361408], [1239945, 158712960]]

    try:
        query5 = 'Select SigFrameCount, ParentHnd, TotalFrameCount \
                  from AnalyzerPortResults'
        data = sql_utils.get_all_chart_data(query5, "SINGLE", [filename])
    except RuntimeError as e:
        assert 'ERROR: Expected one data column per row' in str(e)

    try:
        query6 = 'Select SigFrameCount, ParentHnd, TotalFrameCount \
                  from AnalyzerPortResults'
        data = sql_utils.get_all_chart_data(query6, "PAIR", [filename])
    except RuntimeError as e:
        assert 'ERROR: Expected two data columns per row' in str(e)
def get_series_data(result_file_list):
    this_cmd = get_this_cmd()
    series = this_cmd.GetCollection('Series')
    series_data_type = this_cmd.Get('SeriesDataType')
    new_series = []
    for s in series:
        if is_sql_query(s):
            new_series.append(sql_utils.get_all_chart_data(s,
                                                           series_data_type,
                                                           result_file_list))
        else:
            if series_data_type == "SINGLE":
                new_series.append([int(i) for i in s.split(',')])
            else:
                pair_list = []
                split_pairs = re.findall('\[(.*?)\]', s)
                for pair in split_pairs:
                    pair_list.append([int(i) for i in pair.split(',')])
                new_series.append(pair_list)
    return new_series