def test_cis_to_catalog_print_info(tmp_path: pathlib.Path): """Test print_info call.""" config = configparser.ConfigParser() config_path = pathlib.Path( 'tests/data/tasks/cis-to-catalog/test-cis-to-catalog.config') config.read(config_path) section = config['task.cis-to-catalog'] section['output-dir'] = str(tmp_path) tgt = cis_to_catalog.CisToCatalog(section) retval = tgt.print_info() assert retval is None
def test_cis_to_catalog_config_missing_key(tmp_path: pathlib.Path): """Test config missing key.""" config = configparser.ConfigParser() config_path = pathlib.Path( 'tests/data/tasks/cis-to-catalog/test-cis-to-catalog.config') config.read(config_path) section = config['task.cis-to-catalog'] section.pop('output-dir') tgt = cis_to_catalog.CisToCatalog(section) retval = tgt.execute() assert retval == TaskOutcome.FAILURE
def test_cis_to_catalog_input_bogus(tmp_path: pathlib.Path): """Test no input.""" config = configparser.ConfigParser() config_path = pathlib.Path( 'tests/data/tasks/cis-to-catalog/test-cis-to-catalog.config') config.read(config_path) section = config['task.cis-to-catalog'] section['input-dir'] = 'tests/data/tasks/cis-to-catalog/input-bogus' tgt = cis_to_catalog.CisToCatalog(section) retval = tgt.execute() assert retval == TaskOutcome.FAILURE
def test_cis_to_catalog_execute(tmp_path: pathlib.Path): """Test execute call.""" config = configparser.ConfigParser() config_path = pathlib.Path( 'tests/data/tasks/cis-to-catalog/test-cis-to-catalog.config') config.read(config_path) section = config['task.cis-to-catalog'] section['output-dir'] = str(tmp_path) tgt = cis_to_catalog.CisToCatalog(section) retval = tgt.execute() assert retval == TaskOutcome.SUCCESS _validate(tmp_path)
def test_cis_to_catalog_no_file(tmp_path: pathlib.Path, monkeypatch: MonkeyPatch): """Test no file.""" monkeypatch.setattr(cis_to_catalog.CisToCatalog, '_get_filelist', monkey_get_filelist) config = configparser.ConfigParser() config_path = pathlib.Path( 'tests/data/tasks/cis-to-catalog/test-cis-to-catalog.config') config.read(config_path) section = config['task.cis-to-catalog'] tgt = cis_to_catalog.CisToCatalog(section) retval = tgt.execute() assert retval == TaskOutcome.FAILURE
def test_cis_to_catalog_no_input(tmp_path: pathlib.Path): """Test no input.""" config = configparser.ConfigParser() config_path = pathlib.Path( 'tests/data/tasks/cis-to-catalog/test-cis-to-catalog.config') config.read(config_path) section = config['task.cis-to-catalog'] idir = str(tmp_path) ipth = pathlib.Path(idir) / 'foobar' ipth.mkdir(exist_ok=True, parents=True) section['input-dir'] = str(ipth.resolve()) tgt = cis_to_catalog.CisToCatalog(section) retval = tgt.execute() assert retval == TaskOutcome.FAILURE
def test_cis_to_catalog_no_overwrite(tmp_path: pathlib.Path): """Test no overwrite.""" config = configparser.ConfigParser() config_path = pathlib.Path( 'tests/data/tasks/cis-to-catalog/test-cis-to-catalog.config') config.read(config_path) section = config['task.cis-to-catalog'] section['output-dir'] = str(tmp_path) tgt = cis_to_catalog.CisToCatalog(section) retval = tgt.execute() assert retval == TaskOutcome.SUCCESS section['output-overwrite'] = 'false' retval = tgt.execute() assert retval == TaskOutcome.FAILURE
def test_cis_to_catalog_exception(tmp_path: pathlib.Path, monkeypatch: MonkeyPatch): """Test _parse exception.""" monkeypatch.setattr(cis_to_catalog.CisToCatalog, '_parse', monkey_exception) config = configparser.ConfigParser() config_path = pathlib.Path( 'tests/data/tasks/cis-to-catalog/test-cis-to-catalog.config') config.read(config_path) section = config['task.cis-to-catalog'] section['output-dir'] = str(tmp_path) tgt = cis_to_catalog.CisToCatalog(section) retval = tgt.execute() assert retval == TaskOutcome.FAILURE
def test_cis_to_catalog_config_missing(tmp_path: pathlib.Path): """Test config missing.""" section = None tgt = cis_to_catalog.CisToCatalog(section) retval = tgt.execute() assert retval == TaskOutcome.FAILURE