Debian Codegraph @

test/unit/filesystem/ext3_test.py

raw
1 from unittest.mock import (
2 patch, call
3 )
4
5 import unittest.mock as mock
6
7 from kiwi.filesystem.ext3 import FileSystemExt3
8
9
10 class TestFileSystemExt3:
11 @patch('os.path.exists')
12 def setup(self, mock_exists):
13 mock_exists.return_value = True
14 provider = mock.Mock()
15 provider.get_device = mock.Mock(
16 return_value='/dev/foo'
17 )
18 self.ext3 = FileSystemExt3(provider, 'root_dir')
19 self.ext3.setup_mountpoint = mock.Mock(
20 return_value='some-mount-point'
21 )
22
23 @patch('os.path.exists')
24 def setup_method(self, cls, mock_exists):
25 self.setup()
26
27 @patch('kiwi.filesystem.ext3.Command.run')
28 def test_create_on_device(self, mock_command):
29 with patch.dict('os.environ', {'SOURCE_DATE_EPOCH': '0'}):
30 self.ext3.create_on_device('label', 100, uuid='uuid')
31 call = mock_command.call_args_list[0]
32 assert mock_command.call_args_list[0] == \
33 call(['mkfs.ext3', '-L', 'label', '-U', 'uuid', '/dev/foo', '100'])
34 mock_command.reset_mock()
35 self.ext3.create_on_device('label', 100)
36 assert mock_command.call_args_list[0] == call(
37 [
38 'mkfs.ext3',
39 '-L', 'label',
40 '-U', '2453562e-7073-2098-d091-fd7a04dc5434',
41 '/dev/foo',
42 '100'
43 ]
44 )
45
46 @patch('kiwi.filesystem.ext3.Command.run')
47 def test_set_uuid(self, mock_command):
48 self.ext3.set_uuid()
49 assert mock_command.call_args_list == [
50 call(['e2fsck', '-y', '-f', '/dev/foo'], raise_on_error=False),
51 call(['tune2fs', '-f', '-U', 'random', '/dev/foo'])
52 ]