|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import os |
| 4 | +import subprocess |
4 | 5 | import unittest |
5 | 6 | from unittest.mock import patch |
6 | 7 |
|
@@ -134,6 +135,26 @@ def test_create_github_issue_uses_actions_repository(self, _which, check_output) |
134 | 135 | self.assertEqual(issue, "https://example.test/issues/1") |
135 | 136 | self.assertIn("QuantStrategyLab/CryptoStrategies", check_output.call_args.args[0]) |
136 | 137 |
|
| 138 | + @patch( |
| 139 | + "service.briefing_dispatch.subprocess.check_output", |
| 140 | + side_effect=[ |
| 141 | + subprocess.CalledProcessError(1, ["gh"], output="label not found"), |
| 142 | + "https://example.test/issues/2\n", |
| 143 | + ], |
| 144 | + ) |
| 145 | + @patch("service.briefing_dispatch.shutil_which", return_value="/usr/bin/gh") |
| 146 | + def test_create_github_issue_retries_without_missing_labels(self, _which, check_output) -> None: |
| 147 | + with patch.dict(os.environ, {"GITHUB_REPOSITORY": "QuantStrategyLab/CryptoStrategies"}, clear=True): |
| 148 | + issue = create_github_issue( |
| 149 | + title="review disagreement", |
| 150 | + body="details", |
| 151 | + labels=("dual-review", "needs-human"), |
| 152 | + ) |
| 153 | + |
| 154 | + self.assertEqual(issue, "https://example.test/issues/2") |
| 155 | + self.assertIn("--label", check_output.call_args_list[0].args[0]) |
| 156 | + self.assertNotIn("--label", check_output.call_args_list[1].args[0]) |
| 157 | + |
137 | 158 | @patch("service.briefing_dispatch.subprocess.check_output") |
138 | 159 | @patch("service.briefing_dispatch.shutil_which", return_value="/usr/bin/gh") |
139 | 160 | def test_create_github_issue_rejects_invalid_repository(self, _which, check_output) -> None: |
|
0 commit comments