diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-01-01 03:24:40 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-01-01 03:24:40 +0200 |
commit | 6fa9eaafd9faee987a555e8e9c338a82948896ac (patch) | |
tree | c96de42f897627245bcaaf102eb1e5223fd2b8e8 /summainlib_tests.py | |
parent | eb85c7df4fcbeff0c28aeaa9329731dda9aace12 (diff) | |
download | summain-6fa9eaafd9faee987a555e8e9c338a82948896ac.tar.gz |
Implement formatting of symlink targets. With unit test.
Diffstat (limited to 'summainlib_tests.py')
-rw-r--r-- | summainlib_tests.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/summainlib_tests.py b/summainlib_tests.py index cbfb11c..c206155 100644 --- a/summainlib_tests.py +++ b/summainlib_tests.py @@ -51,6 +51,19 @@ class FakeOpenFile(object): pass +class FakeReadlink(object): + + def __init__(self, parent): + self.parent = parent + + def __call__(self, filename): + if stat.S_ISLNK(self.parent.st.st_mode): + self.target = 'symlink' + else: + self.target = '' + return self.target + + class FilesystemObjectTests(unittest.TestCase): def setUp(self): @@ -66,7 +79,8 @@ class FilesystemObjectTests(unittest.TestCase): def new(self, name): return summainlib.FilesystemObject(name, stat_result=self.st, sha1=FakeSha1(), - open_file=FakeOpenFile()) + open_file=FakeOpenFile(), + readlink=FakeReadlink(self)) def test_formats_simple_name_identically(self): self.assertEqual(self.new('foo')['Name'], 'foo') @@ -112,3 +126,10 @@ class FilesystemObjectTests(unittest.TestCase): self.st.st_mode = stat.S_IFDIR | 0755 self.assertEqual(self.new('foo')['Sha-1'], '') + def test_formats_target_correctly_for_symlink(self): + self.st.st_mode = stat.S_IFLNK | 0777 + self.assertEqual(self.new('foo')['Target'], 'symlink') + + def test_formats_target_correctly_for_regular_file(self): + self.assertEqual(self.new('foo')['Target'], '') + |