/ tests / CommitCombinedStatus.py
CommitCombinedStatus.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
 4  # Copyright 2016 John Eskew <jeskew@edx.org>                                   #
 5  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 6  # Copyright 2017 Simon <spam@esemi.ru>                                         #
 7  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 8  #                                                                              #
 9  # This file is part of PyGithub.                                               #
10  # http://pygithub.readthedocs.io/                                              #
11  #                                                                              #
12  # PyGithub is free software: you can redistribute it and/or modify it under    #
13  # the terms of the GNU Lesser General Public License as published by the Free  #
14  # Software Foundation, either version 3 of the License, or (at your option)    #
15  # any later version.                                                           #
16  #                                                                              #
17  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
18  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
19  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
20  # details.                                                                     #
21  #                                                                              #
22  # You should have received a copy of the GNU Lesser General Public License     #
23  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
24  #                                                                              #
25  ################################################################################
26  
27  from datetime import datetime, timezone
28  
29  from . import Framework
30  
31  
32  class CommitCombinedStatus(Framework.TestCase):
33      def setUp(self):
34          super().setUp()
35          self.combined_status = (
36              self.g.get_repo("edx/edx-platform", lazy=True)
37              .get_commit("74e70119a23fa3ffb3db19d4590eccfebd72b659")
38              .get_combined_status()
39          )
40  
41      def testAttributes(self):
42          self.assertEqual(self.combined_status.state, "success")
43          self.assertEqual(
44              self.combined_status.statuses[0].url,
45              "https://api.github.com/repos/edx/edx-platform/statuses/74e70119a23fa3ffb3db19d4590eccfebd72b659",
46          )
47          self.assertEqual(self.combined_status.statuses[1].id, 390603044)
48          self.assertEqual(self.combined_status.statuses[2].state, "success")
49          self.assertEqual(self.combined_status.statuses[3].description, "Build finished.")
50          self.assertEqual(
51              self.combined_status.statuses[4].target_url,
52              "https://build.testeng.edx.org/job/edx-platform-python-unittests-pr/10504/",
53          )
54          self.assertEqual(
55              self.combined_status.statuses[4].created_at,
56              datetime(2015, 12, 14, 13, 24, 18, tzinfo=timezone.utc),
57          )
58          self.assertEqual(
59              self.combined_status.statuses[3].updated_at,
60              datetime(2015, 12, 14, 13, 23, 35, tzinfo=timezone.utc),
61          )
62          self.assertEqual(self.combined_status.sha, "74e70119a23fa3ffb3db19d4590eccfebd72b659")
63          self.assertEqual(self.combined_status.total_count, 6)
64          self.assertEqual(self.combined_status.repository.id, 10391073)
65          self.assertEqual(self.combined_status.repository.full_name, "edx/edx-platform")
66          self.assertEqual(
67              self.combined_status.commit_url,
68              "https://api.github.com/repos/edx/edx-platform/commits/74e70119a23fa3ffb3db19d4590eccfebd72b659",
69          )
70          self.assertEqual(
71              self.combined_status.url,
72              "https://api.github.com/repos/edx/edx-platform/commits/74e70119a23fa3ffb3db19d4590eccfebd72b659/status",
73          )
74          self.assertEqual(
75              repr(self.combined_status),
76              'CommitCombinedStatus(state="success", sha="74e70119a23fa3ffb3db19d4590eccfebd72b659")',
77          )