Example #1
0
 def test_postprocess_testjob_save_attachments(
     self,
     results_url_mock,
     get_from_artifactorial_mock,
     assign_test_log_mock,
     create_testrun_attachment_mock,
 ):
     results_url_mock.return_value = "http://foo.com"
     result_files = ResultFiles()
     result_files.test_results = ExtractedResult()
     result_files.test_results.contents = "abc"
     result_files.test_results.length = 3
     get_from_artifactorial_mock.return_value = result_files
     testjob_mock = MagicMock()
     id_mock = PropertyMock(return_value="999111")
     type(testjob_mock).pk = id_mock
     job_id_mock = PropertyMock(return_value="1234")
     type(testjob_mock).job_id = job_id_mock
     testjob_mock.backend = MagicMock()
     implementation_type_mock = PropertyMock(return_value="lava")
     type(testjob_mock.backend).implementation_type = implementation_type_mock
     definition_mock = PropertyMock(return_value=JOB_DEFINITION)
     type(testjob_mock).definition = definition_mock
     self.plugin.postprocess_testjob(testjob_mock)
     implementation_type_mock.assert_called_once()
     definition_mock.assert_called()
     results_url_mock.assert_called()
     testjob_mock.testrun.metadata.__setitem__.assert_called()
     testjob_mock.testrun.save.assert_called()
     assign_test_log_mock.assert_called()
     create_testrun_attachment_mock.assert_called()
Example #2
0
 def test_postprocess_testjob_interactive(
     self,
     results_url_mock,
     get_from_artifactorial_mock,
     assign_test_log_mock,
     create_testrun_attachment_mock,
 ):
     results_url_mock.return_value = "http://foo.com"
     get_from_artifactorial_mock.return_value = ResultFiles()
     testjob_mock = MagicMock()
     id_mock = PropertyMock(return_value="999111")
     type(testjob_mock).pk = id_mock
     job_id_mock = PropertyMock(return_value="1234")
     type(testjob_mock).job_id = job_id_mock
     testjob_mock.backend = MagicMock()
     implementation_type_mock = PropertyMock(return_value="lava")
     type(testjob_mock.backend
          ).implementation_type = implementation_type_mock
     definition_mock = PropertyMock(return_value=JOB_DEFINITION_INTERACTIVE)
     type(testjob_mock).definition = definition_mock
     testjob_target = MagicMock()
     project_settings_mock = PropertyMock(return_value='{}')
     type(testjob_target).project_settings = project_settings_mock
     type(testjob_mock).target = testjob_target
     self.plugin.postprocess_testjob(testjob_mock)
     implementation_type_mock.assert_called_once_with()
     definition_mock.assert_called_with()
     results_url_mock.assert_called_with()
     testjob_mock.testrun.metadata.__setitem__.assert_called_with(
         'tradefed_results_url_1234', 'http://foo.com')
     testjob_mock.testrun.save.assert_called_with()
     assign_test_log_mock.assert_not_called()
     create_testrun_attachment_mock.assert_not_called()
Example #3
0
 def test_postprocess_testjob_save_attachments(
     self,
     results_url_mock,
     get_from_artifactorial_mock,
     assign_test_log_mock,
     create_testrun_attachment_mock,
 ):
     results_url_mock.return_value = "http://foo.com"
     result_files = ResultFiles()
     result_files.test_results = ExtractedResult()
     result_files.test_results.contents = BytesIO("abc".encode("utf-8"))
     result_files.test_results.length = 3
     get_from_artifactorial_mock.return_value = result_files
     testjob_mock = MagicMock()
     id_mock = PropertyMock(return_value="999111")
     type(testjob_mock).pk = id_mock
     job_id_mock = PropertyMock(return_value="1234")
     type(testjob_mock).job_id = job_id_mock
     testjob_mock.backend = MagicMock()
     implementation_type_mock = PropertyMock(return_value="lava")
     type(testjob_mock.backend
          ).implementation_type = implementation_type_mock
     definition_mock = PropertyMock(return_value=JOB_DEFINITION)
     type(testjob_mock).definition = definition_mock
     testjob_target = MagicMock()
     project_settings_mock = PropertyMock(return_value='{}')
     type(testjob_target).project_settings = project_settings_mock
     type(testjob_mock).target = testjob_target
     self.plugin.postprocess_testjob(testjob_mock)
     implementation_type_mock.assert_called_once_with()
     definition_mock.assert_called_with()
     results_url_mock.assert_called_with()
     testjob_mock.testrun.metadata.__setitem__.assert_called_with(
         'tradefed_results_url_1234', 'http://foo.com')
     testjob_mock.testrun.save.assert_called_with()
     # uncomment when moving to python 3.6
     #assign_test_log_mock.assert_called()
     create_testrun_attachment_mock.assert_called_with(
         testjob_mock.testrun, 'test_results.xml',
         result_files.test_results, 'application/xml')
Example #4
0
 def test_get_from_artifactorial_empty_results(self, download_results_mock):
     suite_name = "2_bar"
     download_results_mock.return_value = ResultFiles()
     testjob_mock = Mock()
     testjob_mock.backend.get_implementation().proxy.results.get_testjob_suites_list_yaml.return_value = (
         SUITES
     )
     testjob_mock.backend.get_implementation().proxy.results.get_testsuite_results_yaml.return_value = (
         "[]"
     )
     job_id_mock = PropertyMock(return_value=999)
     type(testjob_mock).job_id = job_id_mock
     result = self.plugin._get_from_artifactorial(testjob_mock, suite_name)
     job_id_mock.assert_called()
     testjob_mock.backend.get_implementation().proxy.results.get_testjob_suites_list_yaml.assert_called_once()
     testjob_mock.backend.get_implementation().proxy.results.get_testsuite_results_yaml.assert_called()
     self.assertIsNone(result)