Example #1
0
def avg_sql2subunit(output=sys.stdout):
    session = api.get_session()
    tests = api.get_all_tests(session=session)
    session.close()
    output = subunit.v2.StreamResultToBytes(output)
    output.startTestRun()
    for test in tests:
        if not test.run_time:
            continue
        start_time = datetime.datetime.now()
        stop_time = start_time + datetime.timedelta(0, test.run_time)
        write_test(output, start_time, stop_time, 'success', test.test_id, [])
    output.stopTestRun()
Example #2
0
def avg_sql2subunit(output=sys.stdout):
    session = api.get_session()
    tests = api.get_all_tests(session=session)
    session.close()
    output = subunit.v2.StreamResultToBytes(output)
    output.startTestRun()
    for test in tests:
        if not test.run_time:
            continue
        start_time = datetime.datetime.now()
        stop_time = start_time + datetime.timedelta(0, test.run_time)
        write_test(output, start_time, stop_time, 'success', test.test_id, [])
    output.stopTestRun()
Example #3
0
def generate_series():
    session = api.get_session()
    test_dict = {}
    if not CONF.start_date and not CONF.stop_date:
        tests = api.get_all_tests(session)
        for test in tests:
            if CONF.command.test_ids:
                if test.test_id in CONF.command.test_ids:
                    test_dict[test.test_id] = {
                        'success': int(test.success),
                        'failure': int(test.failure),
                    }
            else:
                test_dict[test.test_id] = {
                    'success': int(test.success),
                    'failure': int(test.failure),
                }
    else:
        start_date = None
        stop_date = None
        if CONF.start_date:
            start_date = date_parser.parse(CONF.start_date)
        if CONF.stop_date:
            stop_date = date_parser.parse(CONF.stop_date)
        if CONF.command.test_ids:
            ids = [api.get_id_from_test_id(x) for x in CONF.command.test_ids]
        else:
            ids = api.get_ids_for_all_tests(session)
        for test in ids:
            test_dict[test] = api.get_test_counts_in_date_range(
                test, start_date, stop_date, session)
    if CONF.command.no_success_graph:
        for test in test_dict:
            test_dict[test].pop('success')
    if CONF.command.skip_graph:
        for test in test_dict:
            if not test_dict[test].get('skips'):
                test_id = api.get_id_from_test_id(test)
                test_dict[test]['skips'] = api.get_skip_counts(test_id)
    session.close()
    if not CONF.title:
        title = "Test status counts"
    else:
        title = CONF.title
    df = pd.DataFrame.from_dict(test_dict, orient='index')
    plot = df.plot(kind='barh', stacked=True).set_title(title)
    fig = plot.get_figure()
    fig.savefig(CONF.output)
Example #4
0
def generate_series():
    session = api.get_session()
    test_dict = {}
    if not CONF.start_date and not CONF.stop_date:
        tests = api.get_all_tests(session)
        for test in tests:
            if CONF.command.test_ids:
                if test.test_id in CONF.command.test_ids:
                    test_dict[test.test_id] = {
                        'success': int(test.success),
                        'failure': int(test.failure),
                    }
            else:
                test_dict[test.test_id] = {
                    'success': int(test.success),
                    'failure': int(test.failure),
                }
    else:
        start_date = None
        stop_date = None
        if CONF.start_date:
            start_date = date_parser.parse(CONF.start_date)
        if CONF.stop_date:
            stop_date = date_parser.parse(CONF.stop_date)
        if CONF.command.test_ids:
            ids = [api.get_id_from_test_id(x) for x in CONF.command.test_ids]
        else:
            ids = api.get_ids_for_all_tests(session)
        for test in ids:
            test_dict[test] = api.get_test_counts_in_date_range(
                test, start_date, stop_date, session)
    if CONF.command.no_success_graph:
        for test in test_dict:
            test_dict[test].pop('success')
    if CONF.command.skip_graph:
        for test in test_dict:
            if not test_dict[test].get('skips'):
                test_id = api.get_id_from_test_id(test)
                test_dict[test]['skips'] = api.get_skip_counts(test_id)
    session.close()
    if not CONF.title:
        title = "Test status counts"
    else:
        title = CONF.title
    df = pd.DataFrame.from_dict(test_dict, orient='index')
    plot = df.plot(kind='barh', stacked=True).set_title(title)
    fig = plot.get_figure()
    fig.savefig(CONF.output)
Example #5
0
def get_tests():
    with session_scope() as session:
        db_tests = api.get_all_tests(session)
        tests = [test.to_dict() for test in db_tests]
        return jsonify({'tests': tests})
Example #6
0
 def test_create_test(self):
     api.create_test('1234')
     res = api.get_all_tests()
     self.assertEqual(len(res), 1)
     self.assertEqual(res[0].test_id, '1234')
Example #7
0
 def test_create_test(self):
     api.create_test('1234')
     res = api.get_all_tests()
     self.assertEqual(len(res), 1)
     self.assertEqual(res[0].test_id, '1234')
Example #8
0
def get_tests():
    with session_scope() as session:
        db_tests = api.get_all_tests(session)
        tests = [test.to_dict() for test in db_tests]
        return jsonify({'tests': tests})
Example #9
0
def get_tests():
    session = get_session()
    db_tests = api.get_all_tests(session)
    tests = [test.to_dict() for test in db_tests]
    return jsonify({'tests': tests})