/ tests / Issue214.py
Issue214.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2013 David Farr <david.farr@sap.com>                               #
 4  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
 5  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 6  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 7  #                                                                              #
 8  # This file is part of PyGithub.                                               #
 9  # http://pygithub.readthedocs.io/                                              #
10  #                                                                              #
11  # PyGithub is free software: you can redistribute it and/or modify it under    #
12  # the terms of the GNU Lesser General Public License as published by the Free  #
13  # Software Foundation, either version 3 of the License, or (at your option)    #
14  # any later version.                                                           #
15  #                                                                              #
16  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
17  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
18  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
19  # details.                                                                     #
20  #                                                                              #
21  # You should have received a copy of the GNU Lesser General Public License     #
22  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
23  #                                                                              #
24  ################################################################################
25  
26  from . import Framework
27  
28  
29  class Issue214(Framework.TestCase):  # https://github.com/jacquev6/PyGithub/issues/214
30      def setUp(self):
31          super().setUp()
32          self.repo = self.g.get_user().get_repo("PyGithub")
33          self.issue = self.repo.get_issue(1)
34  
35      def testAssignees(self):
36          self.assertTrue(self.repo.has_in_assignees("farrd"))
37          self.assertFalse(self.repo.has_in_assignees("fake"))
38  
39      def testCollaborators(self):
40          self.assertTrue(self.repo.has_in_collaborators("farrd"))
41          self.assertFalse(self.repo.has_in_collaborators("fake"))
42  
43          self.assertFalse(self.repo.has_in_collaborators("marcmenges"))
44          self.repo.add_to_collaborators("marcmenges")
45          self.assertTrue(self.repo.has_in_collaborators("marcmenges"))
46  
47          self.repo.remove_from_collaborators("marcmenges")
48          self.assertFalse(self.repo.has_in_collaborators("marcmenges"))
49  
50      def testEditIssue(self):
51          self.assertEqual(self.issue.assignee, None)
52  
53          self.issue.edit(assignee="farrd")
54          self.assertEqual(self.issue.assignee.login, "farrd")
55  
56          self.issue.edit(assignee=None)
57          self.assertEqual(self.issue.assignee, None)
58  
59      def testCreateIssue(self):
60          issue = self.repo.create_issue("Issue created by PyGithub", assignee="farrd")
61          self.assertEqual(issue.assignee.login, "farrd")
62  
63      def testGetIssues(self):
64          issues = self.repo.get_issues(assignee="farrd")
65  
66          for issue in issues:
67              self.assertEqual(issue.assignee.login, "farrd")