Пример #1
0
def test_profile_to_osco_execute_no_overwrite(tmp_path):
    """Test execute call no overwrite."""
    config = configparser.ConfigParser()
    config_path = pathlib.Path(
        'tests/data/tasks/profile-to-osco/profile-to-osco-no-overwrite.config')
    config.read(config_path)
    section = config['task.profile-to-osco']
    d_expected = pathlib.Path(section['output-dir'])
    d_produced = tmp_path
    section['output-dir'] = str(d_produced)
    tgt = profile_to_osco.ProfileToOsco(section)
    retval = tgt.simulate()
    assert retval == TaskOutcome.SIM_SUCCESS
    assert len(os.listdir(str(tmp_path))) == 0
    retval = tgt.execute()
    assert retval == TaskOutcome.SUCCESS
    list_dir = os.listdir(d_produced)
    assert len(list_dir) == 1
    assert d_expected != d_produced
    for fn in list_dir:
        f_expected = d_expected / fn
        f_produced = d_produced / fn
        result = text_files_equal(f_expected, f_produced)
        assert (result)
    retval = tgt.execute()
    assert retval == TaskOutcome.FAILURE
Пример #2
0
def test_profile_to_osco_print_info(tmp_path):
    """Test print_info call."""
    config = configparser.ConfigParser()
    config_path = pathlib.Path(
        'tests/data/tasks/profile-to-osco/profile-to-osco.config')
    config.read(config_path)
    section = config['task.profile-to-osco']
    section['output-dir'] = str(tmp_path)
    tgt = profile_to_osco.ProfileToOsco(section)
    retval = tgt.print_info()
    assert retval is None
Пример #3
0
def test_profile_to_osco_execute_no_output_dir(tmp_path):
    """Test execute call no output file."""
    config = configparser.ConfigParser()
    config_path = pathlib.Path(
        'tests/data/tasks/profile-to-osco/profile-to-osco-no-output-dir.config'
    )
    config.read(config_path)
    section = config['task.profile-to-osco']
    tgt = profile_to_osco.ProfileToOsco(section)
    retval = tgt.execute()
    assert retval == TaskOutcome.FAILURE
Пример #4
0
def test_profile_to_osco_simulate(tmp_path):
    """Test simulate call."""
    config = configparser.ConfigParser()
    config_path = pathlib.Path(
        'tests/data/tasks/profile-to-osco/profile-to-osco.config')
    config.read(config_path)
    section = config['task.profile-to-osco']
    section['output-dir'] = str(tmp_path)
    tgt = profile_to_osco.ProfileToOsco(section)
    retval = tgt.simulate()
    assert retval == TaskOutcome.SIM_SUCCESS
    assert len(os.listdir(str(tmp_path))) == 0
Пример #5
0
def _test_profile_to_osco_execute_common(tmp_path, config):
    """Test execute call."""
    section = config['task.profile-to-osco']
    d_expected = pathlib.Path(section['output-dir'])
    d_produced = tmp_path
    section['output-dir'] = str(d_produced)
    tgt = profile_to_osco.ProfileToOsco(section)
    retval = tgt.simulate()
    assert retval == TaskOutcome.SIM_SUCCESS
    assert len(os.listdir(str(tmp_path))) == 0
    retval = tgt.execute()
    assert retval == TaskOutcome.SUCCESS
    list_dir = os.listdir(d_produced)
    assert len(list_dir) == 1
    assert d_expected != d_produced
    for fn in list_dir:
        f_expected = d_expected / fn
        f_produced = d_produced / fn
        result = text_files_equal(f_expected, f_produced)
        assert (result)
Пример #6
0
def test_profile_to_osco_execute_bogus_config(tmp_path):
    """Test execute call bogus config."""
    section = None
    tgt = profile_to_osco.ProfileToOsco(section)
    retval = tgt.execute()
    assert retval == TaskOutcome.FAILURE