| 1 |
from unittest.mock import patch |
| 2 |
|
| 3 |
import unittest.mock as mock |
| 4 |
|
| 5 |
from kiwi.system.size import SystemSize |
| 6 |
|
| 7 |
|
| 8 |
class TestSystemSize: |
| 9 |
def setup(self): |
| 10 |
self.size = SystemSize('directory') |
| 11 |
|
| 12 |
def setup_method(self, cls): |
| 13 |
self.setup() |
| 14 |
|
| 15 |
def test_customize_ext(self): |
| 16 |
self.size.accumulate_files = mock.Mock( |
| 17 |
return_value=10000 |
| 18 |
) |
| 19 |
assert self.size.customize(42, 'ext3') == 67 |
| 20 |
|
| 21 |
def test_customize_btrfs(self): |
| 22 |
assert self.size.customize(42, 'btrfs') == 63 |
| 23 |
|
| 24 |
def test_customize_xfs(self): |
| 25 |
assert self.size.customize(42, 'xfs') == 63 |
| 26 |
|
| 27 |
@patch('kiwi.system.size.Command.run') |
| 28 |
def test_accumulate_mbyte_file_sizes(self, mock_command): |
| 29 |
assert isinstance(self.size.accumulate_mbyte_file_sizes(['/foo']), int) |
| 30 |
mock_command.assert_called_once_with( |
| 31 |
[ |
| 32 |
'du', '-s', '--apparent-size', '--block-size', '1', |
| 33 |
'--exclude', 'directory/proc', |
| 34 |
'--exclude', 'directory/sys', |
| 35 |
'--exclude', 'directory/dev', |
| 36 |
'--exclude', '/foo', 'directory' |
| 37 |
] |
| 38 |
) |
| 39 |
|
| 40 |
@patch('kiwi.system.size.Command.run') |
| 41 |
def test_accumulate_files(self, mock_command): |
| 42 |
assert isinstance(self.size.accumulate_files(), int) |
| 43 |
mock_command.assert_called_once_with( |
| 44 |
['bash', '-c', 'find directory | wc -l'] |
| 45 |
) |