diff --git a/src/cryptobox/tests/test.cryptoboxtools.py b/src/cryptobox/tests/test.core.blockdevice.py similarity index 65% rename from src/cryptobox/tests/test.cryptoboxtools.py rename to src/cryptobox/tests/test.core.blockdevice.py index 0a03a85..003273b 100755 --- a/src/cryptobox/tests/test.cryptoboxtools.py +++ b/src/cryptobox/tests/test.core.blockdevice.py @@ -25,44 +25,36 @@ __revision__ = "$Id$" -import cryptobox.core.tools as cbx_tools +import cryptobox.core.blockdevice as blockdevice from cryptobox.tests.base import CommonTestClass +from cryptobox.core.exceptions import CBInternalError import os -class CryptoBoxToolsTests(CommonTestClass): +class CoreBlockDevice(CommonTestClass): """All unittests for cryptoboxtools """ def test_find_major_minor_of_device(self): """check the find_major_minor_of_device function """ - func = cbx_tools.find_major_minor_of_device - self.assertTrue(func(os.path.devnull) == (1, 3)) + func = blockdevice.get_blockdevice + self.assertTrue(func('/dev/ram0').devnum == (1, 0)) self.assertTrue(func("/dev/nothere") is None) - def test_find_major_minor_device(self): - """check the find_major_minor_device function - """ - func = cbx_tools.find_major_minor_device - path = os.path.join(os.path.sep, "dev") - self.assertTrue(os.path.devnull in func(path, 1, 3)) - self.assertFalse(os.path.devnull in func(path, 2, 3)) - self.assertFalse(None in func(path, 17, 23)) - - def test_is_part_of_blockdevice(self): """check the is_part_of_blockdevice function """ - func = cbx_tools.is_part_of_blockdevice + get_device = lambda devname: blockdevice.get_blockdevice(devname) + func = lambda parent, child: get_device(parent).is_parent_of(get_device(child)) + func_raw = lambda parent: get_device(parent).is_parent_of self.assertTrue(func(self.blockdevice, self.device)) self.assertFalse(func(self.blockdevice, self.blockdevice)) self.assertFalse(func(self.device, self.blockdevice)) self.assertFalse(func(self.device, self.device)) self.assertFalse(func(self.blockdevice, "/dev/hde1")) - self.assertFalse(func(None, self.blockdevice)) - self.assertFalse(func(self.blockdevice, None)) - self.assertFalse(func(None, "")) - self.assertFalse(func("loop0", "loop1")) + self.assertFalse(func("ram0", "ram1")) + self.assertFalse(func_raw(self.blockdevice), None)) + self.assertRaises(CBInternalError, func_raw(self.blockdevice), "")