| 1 |
from unittest.mock import patch |
| 2 |
|
| 3 |
import unittest.mock as mock |
| 4 |
|
| 5 |
from kiwi.filesystem.fat32 import FileSystemFat32 |
| 6 |
|
| 7 |
|
| 8 |
class TestFileSystemFat32: |
| 9 |
@patch('os.path.exists') |
| 10 |
def setup(self, mock_exists): |
| 11 |
mock_exists.return_value = True |
| 12 |
provider = mock.Mock() |
| 13 |
provider.get_device = mock.Mock( |
| 14 |
return_value='/dev/foo' |
| 15 |
) |
| 16 |
self.fat32 = FileSystemFat32(provider, 'root_dir') |
| 17 |
self.fat32.setup_mountpoint = mock.Mock( |
| 18 |
return_value='some-mount-point' |
| 19 |
) |
| 20 |
|
| 21 |
@patch('os.path.exists') |
| 22 |
def setup_method(self, cls, mock_exists): |
| 23 |
self.setup() |
| 24 |
|
| 25 |
@patch('kiwi.filesystem.fat32.Command.run') |
| 26 |
def test_create_on_device(self, mock_command): |
| 27 |
with patch.dict('os.environ', {'SOURCE_DATE_EPOCH': '0'}): |
| 28 |
self.fat32.create_on_device( |
| 29 |
'label', 100, uuid='12345678-1234-5678-1234-567812345678' |
| 30 |
) |
| 31 |
call = mock_command.call_args_list[0] |
| 32 |
assert mock_command.call_args_list[0] == call( |
| 33 |
[ |
| 34 |
'mkdosfs', '-F32', '-I', '-n', 'label', |
| 35 |
'-i', '12345678', '/dev/foo', '100' |
| 36 |
] |
| 37 |
) |
| 38 |
mock_command.reset_mock() |
| 39 |
self.fat32.create_on_device('label', 100) |
| 40 |
assert mock_command.call_args_list[0] == call( |
| 41 |
[ |
| 42 |
'mkdosfs', '-F32', '-I', |
| 43 |
'-n', 'label', |
| 44 |
'-i', '2453562E', |
| 45 |
'/dev/foo', |
| 46 |
'100' |
| 47 |
] |
| 48 |
) |
| 49 |
|
| 50 |
@patch('kiwi.filesystem.fat32.Command.run') |
| 51 |
def test_set_uuid(self, mock_command): |
| 52 |
self.fat32.set_uuid() |
| 53 |
mock_command.assert_called_once_with( |
| 54 |
['mlabel', '-n', '-i', '/dev/foo', '::'] |
| 55 |
) |