Improve swap_link with temp link before removing link.
Update test, now test_swap_link pass.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from swap_link import swap_link
|
||||
|
||||
class TestSwapLink(unittest.TestCase):
|
||||
|
||||
@@ -14,7 +16,13 @@ class TestSwapLink(unittest.TestCase):
|
||||
# TODO: no writing permission on file
|
||||
|
||||
def test_wrong_tgt_file(self):
|
||||
# TODO: non-existing target
|
||||
with self.assertRaises(Exception):
|
||||
swap_link(data_dir+"lnk_dir/tgt_file.txt", data_dir+"inexistent")
|
||||
# TODO: target is link to lnk file (can't have 2 symlinks pointing at one another)
|
||||
True
|
||||
|
||||
def test_fix_link(self):
|
||||
lnk = 'test/data/lnk_dir/tgt_file.txt'
|
||||
tgt = 'test/data/tgt_dir/tgt_file.txt'
|
||||
swap_link(lnk, tgt)
|
||||
print(f"Lnk path resolve:")
|
||||
self.assertEqual(Path(lnk).resolve(), Path(tgt).resolve())
|
||||
Reference in New Issue
Block a user