def test_report_to_github_passing(): gh = unittest.mock.Mock(github.GitHub) gh.list_issues.return_value = [ { "title": "Unrelated issue title", "number": 2345, "url": "https://github.com/googleapis/test1/issues/2345", }, { "title": "Synthesis failed for test1", "number": 1234, "url": "https://github.com/googleapis/test1/issues/1234", }, ] multi.report_to_github( gh=gh, name="test1", repository="googleapis/test1", error=False, output="synth success", ) gh.list_issues.assert_called() gh.create_issue_comment.assert_called() gh.patch_issue.assert_called_with("googleapis/test1", issue_number=1234, state="closed")
def test_report_to_github_first_failure(): gh = unittest.mock.Mock(github.GitHub) gh.list_issues.return_value = [{ "title": "Unrelated issue title", "number": 2345, "url": "https://github.com/googleapis/test1/issues/2345", }] gh.create_issue.return_value = { "url": "https://github.com/googleapis/test1/issues/1234" } multi.report_to_github( gh=gh, name="library-name", repository="googleapis/test1", error=True, output="some error output", ) gh.list_issues.assert_called() gh.create_issue.assert_called()
def test_report_to_github_repeat_failure(): gh = unittest.mock.Mock(github.GitHub) gh.list_issues.return_value = [ { "title": "Unrelated issue title", "number": 2345, "url": "https://github.com/googleapis/test1/issues/2345", }, { "title": "Synthesis failed for test1", "number": 1234, "url": "https://github.com/googleapis/test1/issues/1234", }, ] multi.report_to_github( gh=gh, name="test1", repository="googleapis/test1", error=True, output="some error output", ) gh.list_issues.assert_called() gh.create_issue_comment.assert_called()