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)
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)
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))
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)
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))
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))
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)
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))
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)
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)
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'))
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'))
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'))
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)