From f7c9f837634738da105056a8b66457afa3ff8636 Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Mon, 17 Dec 2018 18:30:52 +0100 Subject: 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. --- tests/ranger/container/test_bookmarks.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') 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) -- cgit 1.4.1-2-gfad0 From f6c7a281c1cde6d754811f64f3227d5623a4d096 Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Mon, 17 Dec 2018 22:22:05 +0100 Subject: corrected for python 2.7 --- tests/ranger/container/test_bookmarks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/ranger/container/test_bookmarks.py b/tests/ranger/container/test_bookmarks.py index 7802bd5d..e76aaaf2 100644 --- a/tests/ranger/container/test_bookmarks.py +++ b/tests/ranger/container/test_bookmarks.py @@ -64,12 +64,12 @@ def test_bookmark_symlink(tmpdir): bookmarkfile_orig = tmpdir.join("bookmarkfile.org") # Create symlink pointing towards the original plain file. - os.symlink(bookmarkfile_orig, bookmarkfile_link) + os.symlink(str(bookmarkfile_orig), str(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) + assert os.path.islink(str(bookmarkfile_link)) + assert not os.path.islink(str(bookmarkfile_orig)) -- cgit 1.4.1-2-gfad0 From 29222004d0baa6f19f9ecba1b03b218716a13cb3 Mon Sep 17 00:00:00 2001 From: Jon Erling Hustadnes Date: Tue, 18 Dec 2018 12:41:13 +0100 Subject: updated original filename --- tests/ranger/container/test_bookmarks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/ranger/container/test_bookmarks.py b/tests/ranger/container/test_bookmarks.py index e76aaaf2..64192c06 100644 --- a/tests/ranger/container/test_bookmarks.py +++ b/tests/ranger/container/test_bookmarks.py @@ -61,7 +61,7 @@ def testbookmarks(tmpdir): def test_bookmark_symlink(tmpdir): # Initialize plain file and symlink paths bookmarkfile_link = tmpdir.join("bookmarkfile") - bookmarkfile_orig = tmpdir.join("bookmarkfile.org") + bookmarkfile_orig = tmpdir.join("bookmarkfile.orig") # Create symlink pointing towards the original plain file. os.symlink(str(bookmarkfile_orig), str(bookmarkfile_link)) -- cgit 1.4.1-2-gfad0