summaryrefslogtreecommitdiff
path: root/ironic_python_agent/tests/unit/test_utils.py
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2021-08-27 13:28:41 +0200
committerDmitry Tantsur <dtantsur@protonmail.com>2021-11-18 13:49:51 +0100
commit89bc73aa0105850c6ae44428642e31802bba3b20 (patch)
treeba07ae4d1f4c9430d6448d07b7527ab74c2a979a /ironic_python_agent/tests/unit/test_utils.py
parent36d4a18fbc7afd873035930a558e971ad4cec12f (diff)
downloadironic-python-agent-89bc73aa0105850c6ae44428642e31802bba3b20.tar.gz
Use two more functions from disk_utils
Change-Id: If01c9cd7f95b4495509369786360741b731161db
Diffstat (limited to 'ironic_python_agent/tests/unit/test_utils.py')
-rw-r--r--ironic_python_agent/tests/unit/test_utils.py85
1 files changed, 0 insertions, 85 deletions
diff --git a/ironic_python_agent/tests/unit/test_utils.py b/ironic_python_agent/tests/unit/test_utils.py
index 2cf2a20b..96d31688 100644
--- a/ironic_python_agent/tests/unit/test_utils.py
+++ b/ironic_python_agent/tests/unit/test_utils.py
@@ -23,7 +23,6 @@ import tarfile
import tempfile
from unittest import mock
-from ironic_lib import disk_utils
from ironic_lib import utils as ironic_utils
from oslo_concurrency import processutils
from oslo_serialization import base64
@@ -35,18 +34,6 @@ from ironic_python_agent import hardware
from ironic_python_agent.tests.unit import base as ironic_agent_base
from ironic_python_agent import utils
-PARTED_OUTPUT_UNFORMATTED = '''Model: whatever
-Disk /dev/sda: 450GB
-Sector size (logical/physical): 512B/512B
-Partition Table: {}
-Disk Flags:
-
-Number Start End Size File system Name Flags
-14 1049kB 5243kB 4194kB bios_grub
-15 5243kB 116MB 111MB fat32 boot, esp
- 1 116MB 2361MB 2245MB ext4
-'''
-
class ExecuteTestCase(ironic_agent_base.IronicAgentTest):
# This test case does call utils.execute(), so don't block access to the
@@ -818,36 +805,6 @@ class TestUtils(ironic_agent_base.IronicAgentTest):
self.assertEqual('gpt', label)
mock_boot_mode.assert_has_calls([])
- @mock.patch.object(utils, 'execute', autospec=True)
- def test_scan_partition_table_type_gpt(self, mocked_execute):
- self._test_scan_partition_table_by_type(mocked_execute, 'gpt', 'gpt')
-
- @mock.patch.object(utils, 'execute', autospec=True)
- def test_scan_partition_table_type_msdos(self, mocked_execute):
- self._test_scan_partition_table_by_type(mocked_execute, 'msdos',
- 'msdos')
-
- @mock.patch.object(utils, 'execute', autospec=True)
- def test_scan_partition_table_type_unknown(self, mocked_execute):
- self._test_scan_partition_table_by_type(mocked_execute, 'whatever',
- 'unknown')
-
- def _test_scan_partition_table_by_type(self, mocked_execute,
- table_type_output,
- expected_table_type):
-
- parted_ret = PARTED_OUTPUT_UNFORMATTED.format(table_type_output)
-
- mocked_execute.side_effect = [
- (parted_ret, None),
- ]
-
- ret = utils.scan_partition_table_type('hello')
- mocked_execute.assert_has_calls(
- [mock.call('parted', '-s', 'hello', '--', 'print')]
- )
- self.assertEqual(expected_table_type, ret)
-
class TestRemoveKeys(testtools.TestCase):
def test_remove_keys(self):
@@ -942,48 +899,6 @@ class TestClockSyncUtils(ironic_agent_base.IronicAgentTest):
self.assertEqual(0, mock_execute.call_count)
-@mock.patch.object(disk_utils, 'list_partitions', autospec=True)
-@mock.patch.object(utils, 'scan_partition_table_type', autospec=True)
-class TestGetEfiPart(testtools.TestCase):
-
- def test_get_efi_part_on_device(self, mocked_type, mocked_parts):
- mocked_parts.return_value = [
- {'number': '1', 'flags': ''},
- {'number': '14', 'flags': 'bios_grub'},
- {'number': '15', 'flags': 'esp, boot'},
- ]
- ret = utils.get_efi_part_on_device('/dev/sda')
- self.assertEqual('15', ret)
-
- def test_get_efi_part_on_device_only_boot_flag_gpt(self, mocked_type,
- mocked_parts):
- mocked_type.return_value = 'gpt'
- mocked_parts.return_value = [
- {'number': '1', 'flags': ''},
- {'number': '14', 'flags': 'bios_grub'},
- {'number': '15', 'flags': 'boot'},
- ]
- ret = utils.get_efi_part_on_device('/dev/sda')
- self.assertEqual('15', ret)
-
- def test_get_efi_part_on_device_only_boot_flag_mbr(self, mocked_type,
- mocked_parts):
- mocked_type.return_value = 'msdos'
- mocked_parts.return_value = [
- {'number': '1', 'flags': ''},
- {'number': '14', 'flags': 'bios_grub'},
- {'number': '15', 'flags': 'boot'},
- ]
- self.assertIsNone(utils.get_efi_part_on_device('/dev/sda'))
-
- def test_get_efi_part_on_device_not_found(self, mocked_type, mocked_parts):
- mocked_parts.return_value = [
- {'number': '1', 'flags': ''},
- {'number': '14', 'flags': 'bios_grub'},
- ]
- self.assertIsNone(utils.get_efi_part_on_device('/dev/sda'))
-
-
@mock.patch.object(utils, '_booted_from_vmedia', autospec=True)
@mock.patch.object(utils, '_check_vmedia_device', autospec=True)
@mock.patch.object(utils, '_find_vmedia_device_by_labels', autospec=True)