/ tests / ConditionalRequestUpdate.py
ConditionalRequestUpdate.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2013 AKFish <akfish@gmail.com>                                     #
 4  # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net>                 #
 5  # Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net>                 #
 6  # Copyright 2015 Uriel Corfa <uriel@corfa.fr>                                  #
 7  # Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com>          #
 8  # Copyright 2018 sfdye <tsfdye@gmail.com>                                      #
 9  #                                                                              #
10  # This file is part of PyGithub.                                               #
11  # http://pygithub.readthedocs.io/                                              #
12  #                                                                              #
13  # PyGithub is free software: you can redistribute it and/or modify it under    #
14  # the terms of the GNU Lesser General Public License as published by the Free  #
15  # Software Foundation, either version 3 of the License, or (at your option)    #
16  # any later version.                                                           #
17  #                                                                              #
18  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
19  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
20  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
21  # details.                                                                     #
22  #                                                                              #
23  # You should have received a copy of the GNU Lesser General Public License     #
24  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
25  #                                                                              #
26  ################################################################################
27  
28  from . import Framework
29  
30  
31  class ConditionalRequestUpdate(Framework.TestCase):
32      def setUp(self):
33          super().setUp()
34          self.repo = self.g.get_repo("akfish/PyGithub", lazy=False)
35  
36      def testDidNotUpdate(self):
37          self.assertFalse(self.repo.update(), msg="The repo is not changed. But update() != False")
38  
39      def testDidUpdate(self):
40          self.assertTrue(
41              self.repo.update(),
42              msg="The repo should be changed by now. But update() != True",
43          )
44  
45      def testUpdateObjectWithoutEtag(self):
46          r = self.g.get_repo("jacquev6/PyGithub", lazy=False)
47          self.assertTrue(r.update())