/ tests / SourceImport.py
SourceImport.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2018 Hayden Fuss <wifu1234@gmail.com>                              #
 4  #                                                                              #
 5  # This file is part of PyGithub.                                               #
 6  # http://pygithub.readthedocs.io/                                              #
 7  #                                                                              #
 8  # PyGithub is free software: you can redistribute it and/or modify it under    #
 9  # the terms of the GNU Lesser General Public License as published by the Free  #
10  # Software Foundation, either version 3 of the License, or (at your option)    #
11  # any later version.                                                           #
12  #                                                                              #
13  # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY  #
14  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    #
15  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
16  # details.                                                                     #
17  #                                                                              #
18  # You should have received a copy of the GNU Lesser General Public License     #
19  # along with PyGithub. If not, see <http://www.gnu.org/licenses/>.             #
20  #                                                                              #
21  ################################################################################
22  
23  from . import Framework
24  
25  
26  class SourceImport(Framework.TestCase):
27      def setUp(self):
28          super().setUp()
29          self.user = self.g.get_user("brix4dayz")
30          self.repo = self.user.get_repo("source-import-test")
31          self.source_import = self.repo.get_source_import()
32  
33      def testAttributes(self):
34          self.assertEqual(self.source_import.authors_count, 1)
35          self.assertEqual(
36              self.source_import.authors_url,
37              "https://api.github.com/repos/brix4dayz/source-import-test/import/authors",
38          )
39          self.assertEqual(self.source_import.has_large_files, False)
40          self.assertEqual(
41              self.source_import.html_url,
42              "https://github.com/brix4dayz/source-import-test/import",
43          )
44          self.assertEqual(self.source_import.large_files_count, 0)
45          self.assertEqual(self.source_import.large_files_size, 0)
46          self.assertEqual(
47              self.source_import.repository_url,
48              "https://api.github.com/repos/brix4dayz/source-import-test",
49          )
50          self.assertEqual(self.source_import.status, "complete")
51          self.assertEqual(self.source_import.status_text, "Done")
52          self.assertEqual(
53              self.source_import.url,
54              "https://api.github.com/repos/brix4dayz/source-import-test/import",
55          )
56          self.assertEqual(self.source_import.use_lfs, "undecided")
57          self.assertEqual(self.source_import.vcs, "mercurial")
58          self.assertEqual(self.source_import.vcs_url, "https://bitbucket.org/hfuss/source-import-test")
59  
60          self.assertEqual(
61              self.source_import.__repr__(),
62              'SourceImport(vcs_url="https://bitbucket.org/hfuss/source-import-test", url="https://api.github.com/repos/brix4dayz/source-import-test/import", status="complete", repository_url="https://api.github.com/repos/brix4dayz/source-import-test")',
63          )
64  
65      def testUpdate(self):
66          # The real test is that update() method passes the header
67          update_ret = self.source_import.update()
68          self.assertTrue(update_ret)
69          self.assertEqual(self.source_import.status, "complete")