Debian Codegraph @

test/unit/archive/cpio_test.py

raw
1 from unittest.mock import patch
2
3 from kiwi.archive.cpio import ArchiveCpio
4
5
6 class TestArchiveCpio:
7 def setup(self):
8 self.archive = ArchiveCpio('foo.cpio')
9
10 def setup_method(self, cls):
11 self.setup()
12
13 @patch('kiwi.archive.cpio.Command.run')
14 def test_create(self, mock_command):
15 self.archive.create('source-dir', ['/boot', '/var/cache'])
16 find_command = \
17 'find . -path ./boot -prune -or -path ./var/cache -prune -o -print'
18 cpio_command = 'cpio --quiet -o -H newc'
19 mock_command.assert_called_once_with(
20 [
21 'bash', '-c',
22 ''.join(
23 [
24 'cd source-dir && ', find_command, ' | ',
25 cpio_command, ' > foo.cpio'
26 ]
27 )
28 ]
29 )
30
31 @patch('kiwi.archive.cpio.Command.run')
32 def test_extract(self, mock_command):
33 self.archive.extract('dest-dir')
34 bash_command = \
35 'cd dest-dir && cat foo.cpio | cpio -i --make-directories'
36 mock_command.assert_called_once_with(
37 ['bash', '-c', bash_command]
38 )