示例#1
0
 def test_info_raise_error_if_strict(self):
     """dasdinfo raises ProcessEdecutionError if strict is True."""
     device_id = random_device_id()
     self.m_subp.side_effect = (
         util.ProcessExecutionError(stdout=self.random_string(),
                                    stderr=self.random_string(),
                                    exit_code=random.randint(1, 255),
                                    cmd=self.random_string()))
     with self.assertRaises(util.ProcessExecutionError):
         dasd.dasdinfo(device_id, strict=True)
示例#2
0
 def test_info_raises_on_failure(self):
     """dasdinfo raises if the process invocation fails."""
     device_id = random_device_id()
     expected_stdout = self.random_string()
     expected_stderr = self.random_string()
     self.m_subp.side_effect = (util.ProcessExecutionError(
         stdout=expected_stdout,
         stderr=expected_stderr,
         exit_code=random.randint(1, 255),
         cmd=self.random_string()))
     with self.assertRaises(util.ProcessExecutionError):
         dasd.dasdinfo(device_id)
示例#3
0
 def test_info_returns_rawoutput(self):
     """dasdinfo returns stdout, stderr if rawoutput is True."""
     device_id = random_device_id()
     expected_stdout = self.random_string()
     expected_stderr = self.random_string()
     self.m_subp.return_value = (expected_stdout, expected_stderr)
     (stdout, stderr) = dasd.dasdinfo(device_id, rawoutput=True)
     self.assertEqual(expected_stdout, stdout)
     self.assertEqual(expected_stderr, stderr)
示例#4
0
 def test_info_returns_partial_dictionary(self):
     """dasdinfo returns partial dictionary on error."""
     device_id = random_device_id()
     self.m_subp.side_effect = (
         util.ProcessExecutionError(stdout=self.info_no_serial,
                                    stderr=self.random_string(),
                                    exit_code=random.randint(1, 255),
                                    cmd=self.random_string()))
     expected = util.load_shell_content(self.info_no_serial)
     self.assertDictEqual(expected, dasd.dasdinfo(device_id))
示例#5
0
 def test_info_returns_rawoutput_on_partial_discovery(self):
     """dasdinfo returns stdout, stderr on error if rawoutput is True."""
     device_id = random_device_id()
     expected_stdout = self.random_string()
     expected_stderr = self.random_string()
     self.m_subp.side_effect = (
         util.ProcessExecutionError(stdout=expected_stdout,
                                    stderr=expected_stderr,
                                    exit_code=random.randint(1, 255),
                                    cmd=self.random_string()))
     (stdout, stderr) = dasd.dasdinfo(device_id, rawoutput=True)
     self.assertEqual(expected_stdout, stdout)
     self.assertEqual(expected_stderr, stderr)
示例#6
0
 def test_info_returns_dictionary(self):
     """dasdinfo returns dictionary of device info."""
     device_id = random_device_id()
     self.m_subp.return_value = (self.info, '')
     expected = util.load_shell_content(self.info)
     self.assertDictEqual(expected, dasd.dasdinfo(device_id))