/ tests / WorkflowJob.py
WorkflowJob.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2021 Jeppe Fihl-Pearson <jeppe@tenzer.dk>                          #
 4  #                                                                              #
 5  # This file is part of PyGithub.                                               #
 6  # http://pygithub.readthedocs.io/                                              #
 7  #                                                                              #
 8  # PyGithub is free software: you can redistribute it and/or modify it under    #
 9  # the terms of the GNU Lesser General Public License as published by the Free  #
10  # Software Foundation, either version 3 of the License, or (at your option)    #
11  # any later version.                                                           #
12  #                                                                              #
13  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
14  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
15  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
16  # details.                                                                     #
17  #                                                                              #
18  # You should have received a copy of the GNU Lesser General Public License     #
19  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
20  #                                                                              #
21  ################################################################################
22  
23  from datetime import datetime, timezone
24  
25  from . import Framework
26  
27  
28  class WorkflowJob(Framework.TestCase):
29      def setUp(self):
30          super().setUp()
31          self.repo = self.g.get_repo("PyGithub/PyGithub")
32          self.job = self.repo.get_workflow_run(4205440316).jobs()[0]
33  
34      def testAttributes(self):
35          self.assertEqual(self.job.id, 11421878319)
36          self.assertEqual(self.job.run_id, 4205440316)
37          self.assertEqual(
38              self.job.run_url,
39              "https://api.github.com/repos/PyGithub/PyGithub/actions/runs/4205440316",
40          )
41          self.assertEqual(self.job.node_id, "CR_kwDOGpsAJ88AAAACqMwILw")
42          self.assertEqual(self.job.head_sha, "06ec040b2eeef6c0316dd5abcda0608525a3f205")
43          self.assertEqual(
44              self.job.url,
45              "https://api.github.com/repos/PyGithub/PyGithub/actions/jobs/11421878319",
46          )
47          self.assertEqual(
48              self.job.html_url,
49              "https://github.com/PyGithub/PyGithub/actions/runs/4205440316/jobs/7297536068",
50          )
51          self.assertEqual(self.job.status, "completed")
52          self.assertEqual(self.job.conclusion, "success")
53          started_at = datetime(2023, 2, 17, 16, 3, 46, tzinfo=timezone.utc)
54          self.assertEqual(self.job.started_at, started_at)
55          completed_at = datetime(2023, 2, 17, 16, 4, 52, tzinfo=timezone.utc)
56          self.assertEqual(self.job.completed_at, completed_at)
57          self.assertEqual(self.job.name, "test (Python 3.7)")
58          self.assertEqual(
59              self.job.check_run_url,
60              "https://api.github.com/repos/PyGithub/PyGithub/check-runs/11421878319",
61          )
62          self.assertListKeyEqual(
63              self.job.steps,
64              lambda s: s.name,
65              [
66                  "Set up job",
67                  "Run actions/checkout@v2",
68                  "Set up Python",
69                  "Install tox",
70                  "Run tests",
71                  "Upload coverage to Codecov",
72                  "Post Set up Python",
73                  "Post Run actions/checkout@v2",
74                  "Complete job",
75              ],
76          )
77          self.assertEqual(
78              self.job.logs_url(),
79              "https://pipelines.actions.githubusercontent.com/serviceHosts/d560a817-28d4-4544-a539-eb35c2a56899/_apis/pipelines/1/runs/5/signedlogcontent/5?urlExpires=2023-03-15T17%3A02%3A58.1305046Z&urlSigningMethod=HMACV1&urlSignature=abcdefghijklmn",
80          )