summaryrefslogtreecommitdiff
path: root/summainlib_tests.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-01-01 03:24:40 +0200
committerLars Wirzenius <liw@liw.fi>2010-01-01 03:24:40 +0200
commit6fa9eaafd9faee987a555e8e9c338a82948896ac (patch)
treec96de42f897627245bcaaf102eb1e5223fd2b8e8 /summainlib_tests.py
parenteb85c7df4fcbeff0c28aeaa9329731dda9aace12 (diff)
downloadsummain-6fa9eaafd9faee987a555e8e9c338a82948896ac.tar.gz
Implement formatting of symlink targets. With unit test.
Diffstat (limited to 'summainlib_tests.py')
-rw-r--r--summainlib_tests.py23
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'], '')
+