def test_report_on_fail(self, app, caplog): self.get_file_contents.return_value = CONFIG_TEMPLATE_ARTIFACT_2 self.get_artifacts.return_value = [{ "path": "raw-test-output/go-test-report.xml", "pretty_path": "raw-test-output/go-test-report.xml", "node_index": 0, "url": "https://24-88881093-gh.circle-artifacts.com/0/raw-test-output/go-test-report.xml" }, { "path": "raw-test-output/go-test.out", "pretty_path": "raw-test-output/go-test.out", "node_index": 0, "url": "https://24-88881093-gh.circle-artifacts.com/0/raw-test-output/go-test.out" }] payload = self.basic_payload() payload['status'] = "cancelled" with app.app_context(): with caplog.at_level(logging.DEBUG): set_commit_status_for_artifacts(self.repo_handler, payload, {}) self.set_status.assert_called_once_with( 'success', 'Something else', 'other', '2.0', 'https://24-88881093-gh.circle-artifacts.com/0/raw-test-output/go-test.out' )
def test_skip(self, app): self.get_file_contents.return_value = CONFIG_TEMPLATE.format( enabled="false") with app.app_context(): set_commit_status_for_artifacts(self.repo_handler, self.basic_payload(), {}) assert self.set_status.call_count == 0
def test_artifacts(self, app, caplog): self.get_file_contents.return_value = CONFIG_TEMPLATE_ARTIFACT_2 self.get_artifacts.return_value = [{ "path": "raw-test-output/go-test-report.xml", "pretty_path": "raw-test-output/go-test-report.xml", "node_index": 0, "url": "https://24-88881093-gh.circle-artifacts.com/0/raw-test-output/go-test-report.xml" }, { "path": "raw-test-output/go-test.out", "pretty_path": "raw-test-output/go-test.out", "node_index": 0, "url": "https://24-88881093-gh.circle-artifacts.com/0/raw-test-output/go-test.out" }] with app.app_context(): with caplog.at_level(logging.DEBUG): set_commit_status_for_artifacts(self.repo_handler, self.basic_payload(), {}) circle_records = [ r for r in caplog.records if r.name == 'baldrick.plugins.circleci_artifacts' ] assert len(circle_records) == 3 assert "test/testbot" in caplog.text assert "https://24-88881093-gh.circle-artifacts.com/0/raw-test-output/go-test-report.xml" in caplog.text assert "https://24-88881093-gh.circle-artifacts.com/0/raw-test-output/go-test.out" in caplog.text args = [ call( 'success', 'Click details to preview the HTML documentation.', 'docs', '2.0', 'https://24-88881093-gh.circle-artifacts.com/0/raw-test-output/go-test-report.xml' ), call( 'success', 'Something else', 'other', '2.0', 'https://24-88881093-gh.circle-artifacts.com/0/raw-test-output/go-test.out' ) ] self.set_status.call_args_list == args assert self.get_artifacts.call_count == 1