Debian Codegraph @

test/unit/storage/mapped_device_test.py

raw
1 from unittest.mock import (
2 patch, Mock
3 )
4 from pytest import raises
5
6 from kiwi.storage.mapped_device import MappedDevice
7
8 from kiwi.exceptions import KiwiMappedDeviceError
9
10
11 class TestMappedDevice:
12 @patch('os.path.exists')
13 def setup(self, mock_path):
14 mock_path.return_value = True
15 self.device_provider = Mock()
16 self.device_provider.is_loop = Mock()
17 self.device = MappedDevice(
18 '/dev/foo', self.device_provider
19 )
20
21 @patch('os.path.exists')
22 def setup_method(self, cls, mock_path):
23 self.setup()
24
25 @patch('os.path.exists')
26 def test_device_not_existingr(self, mock_path):
27 mock_path.return_value = False
28 with raises(KiwiMappedDeviceError):
29 MappedDevice('/dev/foo', Mock())
30
31 def test_get_device(self):
32 assert self.device.get_device() == '/dev/foo'
33
34 def test_is_loop(self):
35 assert self.device.is_loop() == self.device_provider.is_loop()