Esempio n. 1
0
def test_true_no_destination(*_):
    """Creating new profile true path"""
    profile_name = "existing_profile.yaml"
    destination = "my_new_profile.yaml"
    expected_source_file = os.path.join(fake_profiles_path(), profile_name)
    expected_target_file = destination

    new_profile(profile_name, destination)
    # noinspection PyUnresolvedReferences
    yacfg.output.ensure_output_path.assert_not_called()
    # noinspection PyUnresolvedReferences
    shutil.copyfile.assert_called_with(expected_source_file, expected_target_file)
Esempio n. 2
0
def test_destination_problem_exception(*_):
    """Creating new profile true path"""
    profile_name = "existing_profile.yaml"
    destination = "/problematic/directory/my_new_profile.yaml"
    expected_target_dir = os.path.dirname(destination)

    with pytest.raises(OSError):
        new_profile(profile_name, destination)
    # noinspection PyUnresolvedReferences
    yacfg.output.ensure_output_path.assert_called_with(expected_target_dir)
    # noinspection PyUnresolvedReferences
    shutil.copyfile.assert_not_called()
Esempio n. 3
0
def test_true(*_):
    """Creating new profile true path"""
    profile_name = 'existing_profile.yaml'
    destination = '/output/directory/my_new_profile.yaml'
    expected_source_file = os.path.join(fake_profile_path(), profile_name)
    expected_target_file = destination
    expected_target_dir = os.path.dirname(destination)

    new_profile(profile_name, destination)
    # noinspection PyUnresolvedReferences
    yacfg.output.ensure_output_path.assert_called_with(expected_target_dir)
    # noinspection PyUnresolvedReferences
    shutil.copyfile.assert_called_with(expected_source_file,
                                       expected_target_file)