Debian Codegraph @

test/unit/filesystem/btrfs_test.py

raw
1 from unittest.mock import patch
2
3 import unittest.mock as mock
4
5 from kiwi.filesystem.btrfs import FileSystemBtrfs
6
7
8 class TestFileSystemBtrfs:
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.btrfs = FileSystemBtrfs(provider, 'root_dir')
17 self.btrfs.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.btrfs.Command.run')
26 def test_create_on_device(self, mock_command):
27 with patch.dict('os.environ', {'SOURCE_DATE_EPOCH': '0'}):
28 self.btrfs.create_on_device('label', 100, uuid='uuid')
29 call = mock_command.call_args_list[0]
30 assert mock_command.call_args_list[0] == call(
31 [
32 'mkfs.btrfs', '-L', 'label', '-U', 'uuid',
33 '--byte-count', '102400', '/dev/foo'
34 ]
35 )
36 mock_command.reset_mock()
37 self.btrfs.create_on_device('label', 100)
38 assert mock_command.call_args_list[0] == call(
39 [
40 'mkfs.btrfs',
41 '-L', 'label',
42 '-U', '2453562e-7073-2098-d091-fd7a04dc5434',
43 '--byte-count', '102400',
44 '/dev/foo'
45 ]
46 )
47
48 @patch('kiwi.filesystem.btrfs.Command.run')
49 def test_set_uuid(self, mock_command):
50 self.btrfs.set_uuid()
51 mock_command.assert_called_once_with(
52 ['btrfstune', '-f', '-u', '/dev/foo']
53 )