

@mock.patch('bareon.utils.grub.shutil.copy')
@mock.patch('bareon.utils.grub.guess_grub1_datadir', return_value='/fake_datadir')
@mock.patch('bareon.utils.grub.os.remove')
@mock.patch('bareon.utils.grub.os.listdir')
def test_grub1_stage1(self, mock_listdir, mock_remove, mock_datadir, mock_copy):
    mock_listdir.side_effect = [['stage1', 'stage2', 'e2fs_stage_1_5', 'fat_stage1_5'], ['stage1', 'stage2', 'e2fs_stage_1_5', 'fat_stage1_5', 'jfs_stage1_5']]
    gu.grub1_stage1(chroot='/target')
    mock_datadir.assert_called_once_with(chroot='/target')
    expected_remove_calls = [mock.call('/target/boot/grub/stage1'), mock.call('/target/boot/grub/stage2'), mock.call('/target/boot/grub/fat_stage1_5')]
    self.assertEqual(expected_remove_calls, mock_remove.call_args_list)
    expected_copy_calls = [mock.call('/target/fake_datadir/stage1', '/target/boot/grub/stage1'), mock.call('/target/fake_datadir/stage2', '/target/boot/grub/stage2'), mock.call('/target/fake_datadir/fat_stage1_5', '/target/boot/grub/fat_stage1_5'), mock.call('/target/fake_datadir/jfs_stage1_5', '/target/boot/grub/jfs_stage1_5')]
    self.assertEqual(expected_copy_calls, mock_copy.call_args_list)

dataset/ETHPy150Open openstack/bareon/bareon/tests/test_grub_utils.py TestGrubUtils.test_grub1_stage1/original