Ejemplo n.º 1
0
 def test_sfdisk_info(self):
     """verify sfdisk_info returns correct info dictionary for device."""
     self.assertEqual(self.expected, block.sfdisk_info(self.device))
     self.assertEqual([mock.call(self.device)],
                      self.m_get_blockdev_for_partition.call_args_list)
     self.assertEqual(
         [mock.call(['sfdisk', '--json', self.disk], capture=True)],
         self.m_subp.call_args_list)
     self.assertEqual([mock.call(self.m_subp.return_value[0])],
                      self.m_load_json.call_args_list)
Ejemplo n.º 2
0
 def test_sfdisk_info_returns_empty_on_subp_error(self):
     """verify sfdisk_info returns empty dict on subp errors."""
     self.m_subp.side_effect = (util.ProcessExecutionError(
         stdout="",
         stderr="sfdisk: cannot open /dev/vdb: Permission denied",
         exit_code=1))
     self.assertEqual({}, block.sfdisk_info(self.device))
     self.assertEqual([mock.call(self.device)],
                      self.m_get_blockdev_for_partition.call_args_list)
     self.assertEqual(
         [mock.call(['sfdisk', '--json', self.disk], capture=True)],
         self.m_subp.call_args_list)
     self.assertEqual([], self.m_load_json.call_args_list)