| 1 |
from pytest import raises |
| 2 |
from unittest.mock import patch |
| 3 |
|
| 4 |
from kiwi.container.setup.wsl import ContainerSetupWsl |
| 5 |
from kiwi.exceptions import KiwiContainerSetupError |
| 6 |
|
| 7 |
|
| 8 |
class TestContainerSetupAppx: |
| 9 |
@patch('os.path.exists') |
| 10 |
def setup(self, mock_exists): |
| 11 |
self.wsl = ContainerSetupWsl('root_dir') |
| 12 |
|
| 13 |
@patch('os.path.exists') |
| 14 |
def setup_method(self, cls, mock_exists): |
| 15 |
self.setup() |
| 16 |
|
| 17 |
@patch('os.path.exists') |
| 18 |
def test_setup(self, mock_exists): |
| 19 |
|
| 20 |
def exists(path): |
| 21 |
if path == path_to_fail: |
| 22 |
return False |
| 23 |
return True |
| 24 |
|
| 25 |
mock_exists.side_effect = exists |
| 26 |
|
| 27 |
path_to_fail = 'root_dir/etc/wsl-distribution.conf' |
| 28 |
with raises(KiwiContainerSetupError): |
| 29 |
self.wsl.setup() |
| 30 |
|
| 31 |
path_to_fail = 'root_dir/etc/wsl.conf' |
| 32 |
with raises(KiwiContainerSetupError): |
| 33 |
self.wsl.setup() |