Пример #1
0
 def test_import_no_results(self, tmpdir):
     csv_content = str('ID,Title,Test Case I D,Caseimportance,,,')
     csv_file = tmpdir.join('no_results.csv')
     csv_file.write(csv_content)
     csv_file_path = str(csv_file)
     with pytest.raises(Dump2PolarionException) as excinfo:
         csvtools.get_imported_data(csv_file_path)
     assert 'No results read from CSV file' in str(excinfo.value)
Пример #2
0
 def test_import_orig_data(self):
     csv_file = os.path.join(conf.DATA_PATH, 'workitems_ids.csv')
     data = csvtools.get_imported_data(csv_file)
     assert hasattr(data, 'results')
     assert len(data.results) == 15
     assert 'id' in data.results[0]
     assert hasattr(data, 'testrun')
     assert data.testrun == '5_8_0_17'
Пример #3
0
def main(args=None):
    """Main function for cli."""
    args = get_args(args)

    utils.init_log(args.log_level)

    if '.csv' not in args.input_file.lower():
        logger.warn("Make sure the input file '{}' is in CSV format".format(
            args.input_file))

    try:
        records = csvtools.get_imported_data(args.input_file)
    except (EnvironmentError, Dump2PolarionException) as err:
        logger.fatal(err)
        return 1

    # check if all columns required by `pytest_polarion_cfme` are there
    required_columns = {'id': 'ID', 'title': 'Title'}
    missing_columns = [
        required_columns[k] for k in required_columns
        if k not in records.results[0]
    ]
    if missing_columns:
        logger.fatal(
            "The input file '{}' is missing following columns: {}".format(
                args.input_file, ', '.join(missing_columns)))
        return 1

    try:
        dump2sqlite(records, args.output_file)
    # pylint: disable=broad-except
    except Exception as err:
        logger.fatal(err)
        return 1

    return 0
def _get_polarion_testcases(csv_file):
    logger.info('Importing Polarion test cases from {}'.format(csv_file))
    imported_data = get_imported_data(csv_file)
    return {res['title']: res for res in imported_data.results}