cryptonas-branches/pythonrewrite/bin/unittests.CryptoBoxTools.py
lars 9321677078 unittests for CryptoBoxTools
mount/umount moved to separate volume plugins
volume name change moved to 'volume_props' plugin
webinterface for password change (luks) added
attribute "pluginCapabilities" added to plugins
attribute "requestAuth" added to plugins
http authentication implemented (for now: static user database)
2006-10-09 16:44:35 +00:00

48 lines
1.4 KiB
Python
Executable file

#!/usr/bin/env python
import unittest
import CryptoBoxTools
import os
class CryptoBoxToolsTests(unittest.TestCase):
def testGetAbsoluteDeviceName(self):
func = CryptoBoxTools.getAbsoluteDeviceName
self.assertTrue(func("hda") == "/dev/hda")
self.assertTrue(func("loop0") == "/dev/loop0")
self.assertTrue(func(os.path.devnull) == os.path.devnull)
def testFindMajorMinorOfDevice(self):
func = CryptoBoxTools.findMajorMinorOfDevice
self.assertTrue(func("/dev/hda") == (3,0))
self.assertTrue(func("/dev/hda1") == (3,1))
self.assertTrue(func(os.path.devnull) == (1,3))
self.assertTrue(func("/dev/nothere") is None)
def testFindMajorMinorDeviceName(self):
func = CryptoBoxTools.findMajorMinorDeviceName
dir = os.path.join(os.path.sep, "dev")
self.assertTrue(os.path.join(dir,"hda") in func(dir,3,0))
self.assertTrue(os.path.devnull in func(dir,1,3))
self.assertFalse(os.path.devnull in func(dir,2,3))
def testIsPartOfBlockDevice(self):
func = CryptoBoxTools.isPartOfBlockDevice
self.assertTrue(func("/dev/hda", "/dev/hda1"))
self.assertFalse(func("/dev/hda", "/dev/hda"))
self.assertFalse(func("/dev/hda1", "/dev/hda"))
self.assertFalse(func("/dev/hda1", "/dev/hda1"))
self.assertFalse(func("/dev/hda", "/dev/hdb1"))
self.assertFalse(func(None, "/dev/hdb1"))
self.assertFalse(func("/dev/hda", None))
self.assertFalse(func(None, ""))
self.assertFalse(func("loop0", "loop1"))
if __name__ == "__main__":
unittest.main()