10
10
class MiscStorageUtilsTests(unittest.TestCase):
11
def test_zap_disk(self):
12
@patch(STORAGE_LINUX_UTILS + '.check_output')
13
@patch(STORAGE_LINUX_UTILS + '.call')
14
@patch(STORAGE_LINUX_UTILS + '.check_call')
15
def test_zap_disk(self, check_call, call, check_output):
12
16
'''It calls sgdisk correctly to zap disk'''
13
with patch(STORAGE_LINUX_UTILS + '.check_call') as check_call:
14
storage_utils.zap_disk('/dev/foo')
15
check_call.assert_called_with(['sgdisk', '--zap-all', '--clear',
16
'--mbrtogpt', '/dev/foo'])
17
check_output.return_value = '200\n'
18
storage_utils.zap_disk('/dev/foo')
19
call.assert_any_call(['sgdisk', '--zap-all', '--mbrtogpt',
20
'--clear', '/dev/foo'])
21
check_output.assert_any_call(['blockdev', '--getsz', '/dev/foo'])
22
check_call.assert_any_call(['dd', 'if=/dev/zero', 'of=/dev/foo',
24
check_call.assert_any_call(['dd', 'if=/dev/zero', 'of=/dev/foo',
25
'bs=512', 'count=100', 'seek=100'])
18
27
@patch(STORAGE_LINUX_UTILS + '.stat')
19
28
@patch(STORAGE_LINUX_UTILS + '.S_ISBLK')