示例#1
0
    def test_write_image(self, call_mock, open_mock):
        image_info = self._build_fake_image_info()
        device = '/dev/sda'
        location = standby._image_location(image_info)
        script = standby._path_to_script('shell/write_image.sh')
        command = ['/bin/bash', script, location, device]
        call_mock.return_value = 0

        standby._write_image(image_info, device)
        call_mock.assert_called_once_with(command)

        call_mock.reset_mock()
        call_mock.return_value = 1

        self.assertRaises(errors.ImageWriteError,
                          standby._write_image,
                          image_info,
                          device)

        call_mock.assert_called_once_with(command)
示例#2
0
 def test_image_location(self):
     image_info = self._build_fake_image_info()
     location = standby._image_location(image_info)
     self.assertEqual(location, '/tmp/fake_id')