about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorJon Erling Hustadnes <JonErling.Hustadnes@gmail.com>2018-12-17 18:30:52 +0100
committerJon Erling Hustadnes <JonErling.Hustadnes@gmail.com>2018-12-17 18:47:11 +0100
commitf7c9f837634738da105056a8b66457afa3ff8636 (patch)
treef3b274d9b375d0fd82d18d5c741a585ae3bc9027 /tests
parentbae44ae3c7440c00acf65ba4c26a0fd2a0f78c3a (diff)
downloadranger-f7c9f837634738da105056a8b66457afa3ff8636.tar.gz
Added check if bookmark file is a symlink.
If it is, the os.rename is performed on the original file path instead
of overwriting the symlink.
Diffstat (limited to 'tests')
-rw-r--r--tests/ranger/container/test_bookmarks.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ranger/container/test_bookmarks.py b/tests/ranger/container/test_bookmarks.py
index 6fba2a3d..7802bd5d 100644
--- a/tests/ranger/container/test_bookmarks.py
+++ b/tests/ranger/container/test_bookmarks.py
@@ -56,3 +56,20 @@ def testbookmarks(tmpdir):
         secondstore.update_if_outdated()
     secondstore.update = origupdate
     secondstore.update_if_outdated()
+
+
+def test_bookmark_symlink(tmpdir):
+    # Initialize plain file and symlink paths
+    bookmarkfile_link = tmpdir.join("bookmarkfile")
+    bookmarkfile_orig = tmpdir.join("bookmarkfile.org")
+
+    # Create symlink pointing towards the original plain file.
+    os.symlink(bookmarkfile_orig, bookmarkfile_link)
+
+    # Initialize the bookmark file and save the file.
+    bmstore = Bookmarks(str(bookmarkfile_link))
+    bmstore.save()
+
+    # Once saved, the bookmark file should still be a symlink pointing towards the plain file.
+    assert os.path.islink(bookmarkfile_link)
+    assert not os.path.islink(bookmarkfile_orig)