| 1 |
from unittest.mock import patch |
| 2 |
|
| 3 |
import unittest.mock as mock |
| 4 |
|
| 5 |
from kiwi.filesystem.swap import FileSystemSwap |
| 6 |
|
| 7 |
|
| 8 |
class TestFileSystemSwap: |
| 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.swap = FileSystemSwap(provider, 'root_dir') |
| 17 |
self.swap.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.swap.Command.run') |
| 26 |
def test_create_on_device(self, mock_command): |
| 27 |
self.swap.create_on_device('label') |
| 28 |
call = mock_command.call_args_list[0] |
| 29 |
assert mock_command.call_args_list[0] == \ |
| 30 |
call(['mkswap', '-L', 'label', '/dev/foo']) |