def test_getAllRoles(self):
     """
     Expecting an empty tuple when there are no user or group roles
     attributes.
     """
     class Dummy:
         pass
     obj = Dummy()
     local_roles = LocalRoles(obj)
     self.assertEqual((), tuple(local_roles.getAllRoles()))
 def test_getAllRoles_1(self):
     """
     Expecting an empty tuple when the user or group roles attributes
     are None
     """
     class Dummy:
         user_roles = None
         group_roles = None
     obj = Dummy()
     local_roles = LocalRoles(obj)
     self.assertEqual((), tuple(local_roles.getAllRoles()))
 def test_getAllRoles_2(self):
     """
     Expecting an empty tuple when the user or group roles attributes
     are dictionaries.
     """
     class Dummy:
         user_roles = {}
         group_roles = {}
     obj = Dummy()
     local_roles = LocalRoles(obj)
     self.assertEqual((), tuple(local_roles.getAllRoles()))
Example #4
0
    def test_getAllRoles(self):
        """
        Expecting an empty tuple when there are no user or group roles 
        attributes.
        """
        class Dummy:
            pass

        obj = Dummy()
        local_roles = LocalRoles(obj)
        self.assertEqual((), tuple(local_roles.getAllRoles()))
Example #5
0
    def test_getAllRoles_1(self):
        """
        Expecting an empty tuple when the user or group roles attributes
        are None
        """
        class Dummy:
            user_roles = None
            group_roles = None

        obj = Dummy()
        local_roles = LocalRoles(obj)
        self.assertEqual((), tuple(local_roles.getAllRoles()))
Example #6
0
    def test_getAllRoles_2(self):
        """
        Expecting an empty tuple when the user or group roles attributes
        are dictionaries.
        """
        class Dummy:
            user_roles = {}
            group_roles = {}

        obj = Dummy()
        local_roles = LocalRoles(obj)
        self.assertEqual((), tuple(local_roles.getAllRoles()))
 def test_getAllRoles_3(self):
     """
     Expecting a list of tuples with users and groups and their respective
     roles.
     """
     class Dummy:
         user_roles = {'user1':['role1'], 'user2':['role2'], 'user3':['role3']}
         group_roles = {'group1':['role1'], 'group2':['role2']}
     obj = Dummy()
     local_roles = LocalRoles(obj)
     result = list(local_roles.getAllRoles())
     result.sort()
     expected = [('user2', 'role2'), ('user3', 'role3'), ('user1', 'role1'), 
                 ('group1', 'role1'), ('group2', 'role2')]
     expected.sort()
     self.assertEqual(expected, result)
Example #8
0
    def test_getAllRoles_3(self):
        """
        Expecting a list of tuples with users and groups and their respective
        roles.
        """
        class Dummy:
            user_roles = {
                'user1': ['role1'],
                'user2': ['role2'],
                'user3': ['role3']
            }
            group_roles = {'group1': ['role1'], 'group2': ['role2']}

        obj = Dummy()
        local_roles = LocalRoles(obj)
        result = list(local_roles.getAllRoles())
        result.sort()
        expected = [('user2', 'role2'), ('user3', 'role3'), ('user1', 'role1'),
                    ('group1', 'role1'), ('group2', 'role2')]
        expected.sort()
        self.assertEqual(expected, result)