Example #1
0
def test_link_with_read_only_dest(file_a, dest):
    dest_file = os.path.join(dest, 'file_a_link')
    utils.remove_write_permission(dest)
    message = str(
        error.InsufficientPermissionsToSubcmdTo(subcmd=SUBCMD, file=dest_file))
    with pytest.raises(error.InsufficientPermissionsToSubcmdTo, match=message):
        dploy.link(file_a, dest_file)
Example #2
0
def test_link_with_write_only_source(file_a, dest):
    dest_file = os.path.join(dest, 'file_a_link')
    utils.remove_read_permission(file_a)
    with pytest.raises(PermissionError) as e:
        dploy.link(file_a, dest_file)
    assert error.InsufficientPermissions(subcmd=SUBCMD,
                                         file=file_a).msg in str(e.value)
Example #3
0
def test_link_with_conflicting_broken_link_at_dest(file_a, dest):
    dest_file = os.path.join(dest, 'file_a_link')
    os.symlink('non_existant_source', dest_file)
    with pytest.raises(ValueError) as e:
        dploy.link(file_a, dest_file)
    assert (error.ConflictsWithExistingLink(
        subcmd=SUBCMD, source=file_a, dest=dest_file).msg in str(e.value))
Example #4
0
def test_link_with_write_only_source(file_a, dest):
    dest_file = os.path.join(dest, 'file_a_link')
    utils.remove_read_permission(file_a)
    with pytest.raises(PermissionError) as e:
        dploy.link(file_a, dest_file)
    assert error.InsufficientPermissions(
        subcmd=SUBCMD, file=file_a).msg in str(e.value)
Example #5
0
def test_link_with_read_only_dest(file_a, dest):
    dest_file = os.path.join(dest, 'file_a_link')
    utils.remove_write_permission(dest)
    with pytest.raises(PermissionError) as e:
        dploy.link(file_a, dest_file)
    assert (error.InsufficientPermissionsToSubcmdTo(
        subcmd=SUBCMD, file=dest_file).msg in str(e.value))
Example #6
0
def test_link_with_read_only_dest(file_a, dest):
    dest_file = os.path.join(dest, 'file_a_link')
    utils.remove_write_permission(dest)
    with pytest.raises(PermissionError) as e:
        dploy.link(file_a, dest_file)
    assert (error.InsufficientPermissionsToSubcmdTo(subcmd=SUBCMD,
                                                    file=dest_file).msg
            in str(e.value))
Example #7
0
def test_link_with_conflicting_broken_link_at_dest(file_a, dest):
    dest_file = os.path.join(dest, 'file_a_link')
    os.symlink('non_existant_source', dest_file)
    message = str(
        error.ConflictsWithExistingLink(subcmd=SUBCMD,
                                        source=file_a,
                                        dest=dest_file))
    with pytest.raises(error.ConflictsWithExistingLink, match=message):
        dploy.link(file_a, dest_file)
Example #8
0
def test_link_with_conflicting_broken_link_at_dest(file_a, dest):
    dest_file = os.path.join(dest, 'file_a_link')
    os.symlink('non_existant_source', dest_file)
    with pytest.raises(ValueError) as e:
        dploy.link(file_a, dest_file)
    assert (error.ConflictsWithExistingLink(subcmd=SUBCMD,
                                            source=file_a,
                                            dest=dest_file).msg
            in str(e.value))
Example #9
0
def test_unstow_folding_with_stray_symlink_in_unfolded_dest_dir(
        source_a, source_b, source_d, dest):
    """
    Given a dest directory with stowed packages that share a unfolded directory,
    that also contains a stray link along with the links created by stowing.

    When the stowed packages are unstowed

    Then the folded directory remains with the single stray symlink
    """
    stray_path = os.path.join(dest, 'aaa', 'ggg')
    dploy.stow([source_a, source_b], dest)
    dploy.link(os.path.join(source_d, 'aaa', 'ggg'), stray_path)
    dploy.unstow([source_a, source_b], dest)
    assert os.path.islink(stray_path)
Example #10
0
def test_link_with_non_existant_dest(source_a):
    non_existant_dest = 'dest'
    with pytest.raises(FileNotFoundError) as e:
        dploy.link(source_a, os.path.join(non_existant_dest, 'source_a_link'))
    assert error.NoSuchFileOrDirectory(
        subcmd=SUBCMD, file=non_existant_dest).msg in str(e.value)
Example #11
0
def test_link_with_file_as_source(file_a, dest):
    dploy.link(file_a, os.path.join(dest, 'file_a'))
    assert os.path.islink(os.path.join(dest, 'file_a'))
Example #12
0
def test_link_with_directory_as_source(source_a, dest):
    dploy.link(source_a, os.path.join(dest, 'source_a_link'))
    assert os.path.islink(os.path.join(dest, 'source_a_link'))
Example #13
0
def test_link_with_file_as_source(file_a, dest):
    dploy.link(file_a, os.path.join(dest, 'file_a'))
    assert os.path.islink(os.path.join(dest, 'file_a'))
Example #14
0
def test_link_with_non_existant_dest(source_a):
    non_existant_dest = 'dest'
    message = str(
        error.NoSuchFileOrDirectory(subcmd=SUBCMD, file=non_existant_dest))
    with pytest.raises(error.NoSuchFileOrDirectory, match=message):
        dploy.link(source_a, os.path.join(non_existant_dest, 'source_a_link'))
Example #15
0
def test_link_with_non_existant_dest(source_a):
    non_existant_dest = 'dest'
    with pytest.raises(FileNotFoundError) as e:
        dploy.link(source_a, os.path.join(non_existant_dest, 'source_a_link'))
    assert error.NoSuchFileOrDirectory(
        subcmd=SUBCMD, file=non_existant_dest).msg in str(e.value)
Example #16
0
def test_link_with_write_only_source(file_a, dest):
    dest_file = os.path.join(dest, 'file_a_link')
    utils.remove_read_permission(file_a)
    message = str(error.InsufficientPermissions(subcmd=SUBCMD, file=file_a))
    with pytest.raises(error.InsufficientPermissions, match=message):
        dploy.link(file_a, dest_file)
Example #17
0
def test_link_with_directory_as_source(source_a, dest):
    dploy.link(source_a, os.path.join(dest, 'source_a_link'))
    assert os.path.islink(os.path.join(dest, 'source_a_link'))