/ tests / Label.py
Label.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net>                 #
 4  # Copyright 2012 Zearin <zearin@gonk.net>                                      #
 5  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
 6  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
 7  # Copyright 2016 Jannis Gebauer <ja.geb@me.com>                                #
 8  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 9  # Copyright 2018 Mateusz Loskot <mateusz@loskot.net>                           #
10  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
11  #                                                                              #
12  # This file is part of PyGithub.                                               #
13  # http://pygithub.readthedocs.io/                                              #
14  #                                                                              #
15  # PyGithub is free software: you can redistribute it and/or modify it under    #
16  # the terms of the GNU Lesser General Public License as published by the Free  #
17  # Software Foundation, either version 3 of the License, or (at your option)    #
18  # any later version.                                                           #
19  #                                                                              #
20  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
21  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
22  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
23  # details.                                                                     #
24  #                                                                              #
25  # You should have received a copy of the GNU Lesser General Public License     #
26  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
27  #                                                                              #
28  ################################################################################
29  
30  from . import Framework
31  
32  
33  class Label(Framework.TestCase):
34      def setUp(self):
35          super().setUp()
36          self.label = self.g.get_user().get_repo("PyGithub").get_label("Bug")
37  
38      def testAttributes(self):
39          self.assertEqual(self.label.color, "e10c02")
40          self.assertEqual(self.label.name, "Bug")
41          self.assertIsNone(self.label.description)
42          self.assertEqual(self.label.url, "https://api.github.com/repos/jacquev6/PyGithub/labels/Bug")
43          self.assertEqual(repr(self.label), 'Label(name="Bug")')
44  
45      def testEdit(self):
46          self.label.edit("LabelEditedByPyGithub", "0000ff", "Description of LabelEditedByPyGithub")
47          self.assertEqual(self.label.color, "0000ff")
48          self.assertEqual(self.label.description, "Description of LabelEditedByPyGithub")
49          self.assertEqual(self.label.name, "LabelEditedByPyGithub")
50          self.assertEqual(
51              self.label.url,
52              "https://api.github.com/repos/jacquev6/PyGithub/labels/LabelEditedByPyGithub",
53          )
54  
55      def testDelete(self):
56          self.label.delete()