| 1 |
import logging |
| 2 |
from unittest.mock import ( |
| 3 |
patch, Mock |
| 4 |
) |
| 5 |
from pytest import ( |
| 6 |
raises, fixture |
| 7 |
) |
| 8 |
|
| 9 |
from kiwi.partitioner import Partitioner |
| 10 |
|
| 11 |
from kiwi.exceptions import KiwiPartitionerSetupError |
| 12 |
|
| 13 |
|
| 14 |
class TestPartitioner: |
| 15 |
@fixture(autouse=True) |
| 16 |
def inject_fixtures(self, caplog): |
| 17 |
self._caplog = caplog |
| 18 |
|
| 19 |
def test_partitioner_not_implemented(self): |
| 20 |
with raises(KiwiPartitionerSetupError): |
| 21 |
Partitioner.new('foo', Mock()) |
| 22 |
|
| 23 |
def test_partitioner_for_arch_not_implemented(self): |
| 24 |
with raises(KiwiPartitionerSetupError): |
| 25 |
Partitioner.new('foo', Mock()) |
| 26 |
|
| 27 |
@patch('kiwi.partitioner.gpt.PartitionerGpt') |
| 28 |
def test_partitioner_gpt(self, mock_gpt): |
| 29 |
storage_provider = Mock() |
| 30 |
Partitioner.new('gpt', storage_provider) |
| 31 |
mock_gpt.assert_called_once_with(storage_provider, None, False) |
| 32 |
|
| 33 |
@patch('kiwi.partitioner.msdos.PartitionerMsDos') |
| 34 |
def test_partitioner_msdos(self, mock_dos): |
| 35 |
storage_provider = Mock() |
| 36 |
Partitioner.new('msdos', storage_provider) |
| 37 |
mock_dos.assert_called_once_with(storage_provider, None, False) |
| 38 |
|
| 39 |
@patch('kiwi.partitioner.dasd.PartitionerDasd') |
| 40 |
def test_partitioner_dasd(self, mock_dasd): |
| 41 |
storage_provider = Mock() |
| 42 |
Partitioner.new('dasd', storage_provider) |
| 43 |
mock_dasd.assert_called_once_with(storage_provider, None, False) |
| 44 |
|
| 45 |
@patch('kiwi.partitioner.dasd.PartitionerDasd') |
| 46 |
def test_partitioner_dasd_with_custom_start_sector(self, mock_dasd): |
| 47 |
storage_provider = Mock() |
| 48 |
with self._caplog.at_level(logging.WARNING): |
| 49 |
Partitioner.new('dasd', storage_provider, 4096) |
| 50 |
mock_dasd.assert_called_once_with(storage_provider, None, False) |