From: Vojtech Trefny <vtrefny(a)redhat.com>
---
tests/formats_test/luks_test.py | 47 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 tests/formats_test/luks_test.py
diff --git a/tests/formats_test/luks_test.py b/tests/formats_test/luks_test.py
new file mode 100644
index 0000000..ab13334
--- /dev/null
+++ b/tests/formats_test/luks_test.py
@@ -0,0 +1,47 @@
+from blivet.formats.luks import LUKS
+
+from blivet.size import Size
+
+from tests import loopbackedtestcase
+
+
+class LUKSTestCase(loopbackedtestcase.LoopBackedTestCase):
+
+ def __init__(self, methodName='run_test'):
+ super().__init__(methodName=methodName, device_spec=[Size("100 MiB")])
+ self.fmt = LUKS(passphrase="password")
+
+ def test_size(self):
+ self.fmt.device = self.loop_devices[0]
+
+ # create and open the luks format
+ self.fmt.create()
+ self.fmt.setup()
+
+ # without update_size_info size should be 0
+ self.assertEqual(self.fmt.current_size, Size(0))
+
+ # get current size
+ self.fmt.update_size_info()
+ self.assertGreater(self.fmt.current_size, Size(0))
+
+ def test_resize(self):
+ self.fmt.device = self.loop_devices[0]
+
+ # create and open the luks format
+ self.fmt.create()
+ self.fmt.setup()
+
+ # get current size to make format resizable
+ self.assertFalse(self.fmt.resizable)
+ self.fmt.update_size_info()
+ self.assertTrue(self.fmt.resizable)
+
+ # resize the format
+ new_size = Size("50 MiB")
+ self.fmt.target_size = new_size
+ self.fmt.do_resize()
+
+ # get current size
+ self.fmt.update_size_info()
+ self.assertEqual(self.fmt.current_size, new_size)
--
To view this commit on github, visit
https://github.com/rhinstaller/blivet/commit/61010101a8c9c53820f1d77f8857...