@@ -259,6 +259,18 @@ def test_submit_and_accounting_require_each_array_task(self):
259259 self .assertEqual (states ["101_0" ], ("COMPLETED" , "0:0" ))
260260 self .assertEqual (states ["101_1" ], ("FAILED" , "1:0" ))
261261
262+ def test_accounting_retries_transient_failure (self ):
263+ responses = [
264+ mock .Mock (returncode = 0 , stdout = "" , stderr = "" ),
265+ mock .Mock (returncode = 1 , stdout = "" , stderr = "Socket timed out" ),
266+ mock .Mock (returncode = 0 , stdout = "101|COMPLETED|0:0\n " , stderr = "" ),
267+ ]
268+ with mock .patch ("slurm.subprocess.run" , side_effect = responses ):
269+ client = slurm .Slurm (poll_seconds = 0 )
270+ client .jobs ["101" ] = None
271+ states = client .wait (("101" ,))
272+ self .assertEqual (states ["101" ], ("COMPLETED" , "0:0" ))
273+
262274 def test_pass_requires_successful_slurm_accounting (self ):
263275 config = runner .Config (
264276 runner .Site ("Example cluster" , "https://cluster.example/" , "Computing resources were provided by" ),
@@ -808,6 +820,26 @@ def test_mpi_startup_failure_requires_complete_signature(self):
808820
809821
810822class GitHubTests (unittest .TestCase ):
823+ def test_read_user_cannot_trigger_pr_validation (self ):
824+ with tempfile .TemporaryDirectory () as directory :
825+ root = Path (directory )
826+ event = root / "event.json"
827+ event .write_text (json .dumps ({
828+ "comment" : {"user" : {"login" : "reader" }},
829+ "issue" : {"number" : 23 },
830+ }), encoding = "utf-8" )
831+ output = root / "output"
832+ environment = {
833+ "GITHUB_EVENT_NAME" : "issue_comment" , "GITHUB_REPOSITORY" : "owner/repo" ,
834+ "GITHUB_EVENT_PATH" : str (event ), "GITHUB_OUTPUT" : str (output ),
835+ }
836+ with mock .patch .dict (os .environ , environment , clear = True ), \
837+ mock .patch ("runner._gh" , return_value = {"permission" : "read" , "role_name" : "read" }) as api :
838+ with self .assertRaisesRegex (ValueError , "commenter needs Triage permission" ):
839+ runner .github_admit ()
840+ api .assert_called_once_with ("repos/owner/repo/collaborators/reader/permission" )
841+ self .assertFalse (output .exists ())
842+
811843 def test_pr_comment_is_created_queued_and_updated_in_place (self ):
812844 source_sha = "a" * 40
813845 with tempfile .TemporaryDirectory () as directory :
@@ -819,7 +851,7 @@ def test_pr_comment_is_created_queued_and_updated_in_place(self):
819851 }), encoding = "utf-8" )
820852 output = root / "output"
821853 admitted = [
822- {"permission" : "triage" },
854+ {"permission" : "read" , "role_name" : " triage" },
823855 {"state" : "open" , "head" : {"repo" : {"full_name" : "owner/fork" }, "sha" : source_sha }},
824856 {"id" : 456 }, {"id" : 123 },
825857 ]
0 commit comments