/ tests / EnterpriseAdmin.py
EnterpriseAdmin.py
 1  ############################ Copyrights and license ############################
 2  #                                                                              #
 3  # Copyright 2023 Yugo Hino <henom06@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  
24  from . import Framework
25  
26  
27  class EnterpriseAdmin(Framework.TestCase):
28      def setUp(self):
29          super().setUp()
30          self.enterprise = self.g.get_enterprise("beaver-group")
31  
32      def testAttributes(self):
33          self.assertEqual(self.enterprise.enterprise, "beaver-group")
34          self.assertEqual(self.enterprise.url, "/enterprises/beaver-group")
35          self.assertEqual(repr(self.enterprise), 'Enterprise(enterprise="beaver-group")')
36  
37      def testGetConsumedLicenses(self):
38          consumed_licenses = self.enterprise.get_consumed_licenses()
39          self.assertEqual(consumed_licenses.total_seats_consumed, 102)
40          self.assertEqual(consumed_licenses.total_seats_purchased, 103)
41  
42      def testGetEnterpriseUsers(self):
43          enterprise_users = self.enterprise.get_consumed_licenses().get_users()
44          enterprise_users_list = [
45              [
46                  users.github_com_login,
47                  users.github_com_name,
48                  users.enterprise_server_user_ids,
49                  users.github_com_user,
50                  users.enterprise_server_user,
51                  users.visual_studio_subscription_user,
52                  users.license_type,
53                  users.github_com_profile,
54                  users.github_com_member_roles,
55                  users.github_com_enterprise_roles,
56                  users.github_com_verified_domain_emails,
57                  users.github_com_saml_name_id,
58                  users.github_com_orgs_with_pending_invites,
59                  users.github_com_two_factor_auth,
60                  users.enterprise_server_primary_emails,
61                  users.visual_studio_license_status,
62                  users.visual_studio_subscription_email,
63                  users.total_user_accounts,
64              ]
65              for users in enterprise_users
66          ]
67          self.assertEqual(len(enterprise_users_list), 102)
68          self.assertEqual(enterprise_users_list[42][0], "beaver-user043")