~oddbloke/cloud-init/fix-gce-az

« back to all changes in this revision

Viewing changes to tests/unittests/test_handler/test_handler_disk_setup.py

  • Committer: Daniel Watkins
  • Date: 2015-07-22 12:06:34 UTC
  • Revision ID: daniel.watkins@canonical.com-20150722120634-wsg8rwzcaanhc2pn
Make full data source available to code that handles mirror selection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from cloudinit.config import cc_disk_setup
 
2
from ..helpers import ExitStack, mock, TestCase
 
3
 
 
4
 
 
5
class TestIsDiskUsed(TestCase):
 
6
 
 
7
    def setUp(self):
 
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)))
 
15
 
 
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()))
 
20
 
 
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()))
 
26
 
 
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()))