summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-26 20:16:31 +0100
committerhut <hut@lavabit.com>2010-01-26 20:16:31 +0100
commit64649898c66f8afb35e01eff8280e46d90fb73ae (patch)
tree42a0e3e5e19515a5d6371b325b0cc3db70cc1ea9
parent5a087b1667813ad75f84d0cfbe38babd428bf5d6 (diff)
downloadranger-64649898c66f8afb35e01eff8280e46d90fb73ae.tar.gz
added testcase for mount_path
-rw-r--r--test/tc_ext.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/tc_ext.py b/test/tc_ext.py
index f6d58033..ea82bbfe 100644
--- a/test/tc_ext.py
+++ b/test/tc_ext.py
@@ -65,5 +65,30 @@ class TestCases(unittest.TestCase):
 			deque((1,2,3)),
 			u(deque((1,2,3,1))))
 
+	def test_mount_path(self):
+		# assuming ismount() is used
+
+		def my_ismount(path):
+			depth = path.count('/')
+			if path.startswith('/media'):
+				return depth == 0 or depth == 2
+			return depth <= 1
+
+		from ranger.ext import mount_path
+		mount_path.ismount = my_ismount
+
+		mp = mount_path.mount_path
+
+		self.assertEqual('/home', mp('/home/hut/porn/bondage'))
+		self.assertEqual('/', mp('/'))
+		self.assertEqual('/media/sdb1', mp('/media/sdb1/foo/bar'))
+		self.assertEqual('/media/sdc2', mp('/media/sdc2/a/b/c/d/e'))
+
+		# TODO: links are not tested but I don't see how its possible
+		# without messing around with mounts.
+		# self.assertEqual('/media/foo',
+		#     mount_path('/media/bar/some_link_to_a_foo_subdirectory'))
+
+
 if __name__ == '__main__':
 	unittest.main()