Milestone.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 sfdye <tsfdye@gmail.com> # 10 # # 11 # This file is part of PyGithub. # 12 # http://pygithub.readthedocs.io/ # 13 # # 14 # PyGithub is free software: you can redistribute it and/or modify it under # 15 # the terms of the GNU Lesser General Public License as published by the Free # 16 # Software Foundation, either version 3 of the License, or (at your option) # 17 # any later version. # 18 # # 19 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # 20 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # 21 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # 22 # details. # 23 # # 24 # You should have received a copy of the GNU Lesser General Public License # 25 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # 26 # # 27 ################################################################################ 28 29 from datetime import date, datetime, timezone 30 31 from . import Framework 32 33 34 class Milestone(Framework.TestCase): 35 def setUp(self): 36 super().setUp() 37 self.milestone = self.g.get_user().get_repo("PyGithub").get_milestone(1) 38 39 def testAttributes(self): 40 self.assertEqual(self.milestone.closed_issues, 2) 41 self.assertEqual( 42 self.milestone.created_at, 43 datetime(2012, 3, 8, 12, 22, 10, tzinfo=timezone.utc), 44 ) 45 self.assertEqual(self.milestone.description, "") 46 self.assertEqual( 47 self.milestone.due_on, 48 datetime(2012, 3, 13, 7, 0, 0, tzinfo=timezone.utc), 49 ) 50 self.assertEqual(self.milestone.id, 93546) 51 self.assertEqual(self.milestone.number, 1) 52 self.assertEqual(self.milestone.open_issues, 0) 53 self.assertEqual(self.milestone.state, "closed") 54 self.assertEqual(self.milestone.title, "Version 0.4") 55 self.assertEqual( 56 self.milestone.url, 57 "https://api.github.com/repos/jacquev6/PyGithub/milestones/1", 58 ) 59 self.assertEqual(self.milestone.creator.login, "jacquev6") 60 self.assertEqual(repr(self.milestone), 'Milestone(title="Version 0.4", number=1)') 61 62 def testEditWithMinimalParameters(self): 63 self.milestone.edit("Title edited by PyGithub") 64 self.assertEqual(self.milestone.title, "Title edited by PyGithub") 65 66 def testEditWithAllParameters(self): 67 self.milestone.edit( 68 "Title edited twice by PyGithub", 69 "closed", 70 "Description edited by PyGithub", 71 due_on=date(2012, 6, 16), 72 ) 73 self.assertEqual(self.milestone.title, "Title edited twice by PyGithub") 74 self.assertEqual(self.milestone.state, "closed") 75 self.assertEqual(self.milestone.description, "Description edited by PyGithub") 76 self.assertEqual( 77 self.milestone.due_on, 78 datetime(2012, 6, 16, 7, 0, 0, tzinfo=timezone.utc), 79 ) 80 81 def testGetLabels(self): 82 self.assertListKeyEqual( 83 self.milestone.get_labels(), 84 lambda l: l.name, 85 ["Public interface", "Project management"], 86 ) 87 88 def testDelete(self): 89 self.milestone.delete()