本文整理汇总了Python中osci.job.Job.retrieveResults方法的典型用法代码示例。如果您正苦于以下问题:Python Job.retrieveResults方法的具体用法?Python Job.retrieveResults怎么用?Python Job.retrieveResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osci.job.Job
的用法示例。
在下文中一共展示了Job.retrieveResults方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRetrieveResults
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import retrieveResults [as 别名]
class TestRetrieveResults(unittest.TestCase):
def setUp(self):
self.job = Job()
def run_retrieve_results(self):
return self.job.retrieveResults('ignored')
def test_no_ip(self):
self.job.node_ip = None
result = self.run_retrieve_results()
self.assertEquals(constants.NO_IP, result)
@mock.patch('osci.job.utils')
def test_status_can_be_retrieved(self, fake_utils):
self.job.node_ip = 'ip'
fake_utils.execute_command.return_value = (
0, 'Reported status\nAnd some\nRubbish', 'err')
result = self.run_retrieve_results()
self.assertEquals('Reported status', result)
@mock.patch('osci.job.utils')
def test_logs_copied(self, fake_utils):
self.job.node_ip = 'ip'
fake_utils.execute_command.return_value = (
0, 'Reported status\nAnd some\nRubbish', 'err')
result = self.run_retrieve_results()
fake_utils.execute_command.assert_called_once_with(
'ssh -q -o BatchMode=yes'
' -o UserKnownHostsFile=/dev/null'
' -o StrictHostKeyChecking=no'
' -i .ssh/jenkins'
' [email protected] cat result.txt',
silent=True, return_streams=True)
@mock.patch('osci.job.utils')
def test_dom0_logs_copied(self, fake_utils):
self.job.node_ip = 'ip'
fake_utils.execute_command.return_value = (
0, 'Reported status\nAnd some\nRubbish', 'err')
result = self.run_retrieve_results()
fake_utils.copy_dom0_logs.assert_called_once_with(
'ip',
'jenkins',
'.ssh/jenkins',
'ignored'
)
@mock.patch('osci.job.utils')
def test_dom0_log_copy_fails(self, fake_utils):
self.job.node_ip = 'ip'
fake_utils.execute_command.return_value = (
0, 'Reported status\nAnd some\nRubbish', 'err')
fake_utils.copy_dom0_logs.side_effect = Exception()
result = self.run_retrieve_results()
self.assertEquals(constants.COPYFAIL, result)
@mock.patch('osci.job.utils')
def test_status_cannot_be_retrieved_old_status_used(self, fake_utils):
self.job.node_ip = 'ip'
self.job.result = 'Aborted: previous result'
fake_utils.execute_command.return_value = (
1, 'Reported status\nAnd some\nRubbish', 'err')
result = self.run_retrieve_results()
self.assertEquals('Aborted: previous result', result)
@mock.patch('osci.job.utils')
def test_status_cannot_be_retrieved_old_status_not_used(self, fake_utils):
self.job.node_ip = 'ip'
self.job.result = 'previous result'
fake_utils.execute_command.return_value = (
1, 'Reported status\nAnd some\nRubbish', 'err')
result = self.run_retrieve_results()
self.assertEquals(constants.NORESULT, result)
@mock.patch('osci.job.utils')
def test_exception_raised(self, fake_utils):
self.job.node_ip = 'ip'
fake_utils.execute_command.side_effect = Exception()
result = self.run_retrieve_results()
self.assertEquals(constants.COPYFAIL, result)