1
from cloudinit.config import cc_disk_setup
2
from ..helpers import ExitStack, mock, TestCase
5
class TestIsDiskUsed(TestCase):
8
super(TestIsDiskUsed, self).setUp()
9
self.patches = ExitStack()
10
mod_name = 'cloudinit.config.cc_disk_setup'
11
self.enumerate_disk = self.patches.enter_context(
12
mock.patch('{0}.enumerate_disk'.format(mod_name)))
13
self.check_fs = self.patches.enter_context(
14
mock.patch('{0}.check_fs'.format(mod_name)))
16
def test_multiple_child_nodes_returns_true(self):
17
self.enumerate_disk.return_value = (mock.MagicMock() for _ in range(2))
18
self.check_fs.return_value = (mock.MagicMock(), None, mock.MagicMock())
19
self.assertTrue(cc_disk_setup.is_disk_used(mock.MagicMock()))
21
def test_valid_filesystem_returns_true(self):
22
self.enumerate_disk.return_value = (mock.MagicMock() for _ in range(1))
23
self.check_fs.return_value = (
24
mock.MagicMock(), 'ext4', mock.MagicMock())
25
self.assertTrue(cc_disk_setup.is_disk_used(mock.MagicMock()))
27
def test_one_child_nodes_and_no_fs_returns_false(self):
28
self.enumerate_disk.return_value = (mock.MagicMock() for _ in range(1))
29
self.check_fs.return_value = (mock.MagicMock(), None, mock.MagicMock())
30
self.assertFalse(cc_disk_setup.is_disk_used(mock.MagicMock()))