def test_getRoles_1(self):
     """
     Expecting an empty list when no user or group roles attributes exist
     """
     class Dummy:
         pass
     obj = Dummy()
     local_roles = LocalRoles(obj)
     self.assertEqual([], local_roles.getRoles('dummy'))
 def test_getRoles_4(self):
     """
     Expecting the list of roles when a user has roles assigned.
     """
     class Dummy:
         user_roles = {'user1': ['role1']}
         group_roles = None
     obj = Dummy()
     local_roles = LocalRoles(obj)
     self.assertEqual(['role1'], local_roles.getRoles('user1'))
 def test_getRoles_5(self):
     """
     Expecting the list of roles when a group has roles assigned.
     """
     class Dummy:
         user_roles = None
         group_roles = {'group1': ['role1', 'role2']}
     obj = Dummy()
     local_roles = LocalRoles(obj)
     self.assertEqual(['role1', 'role2'], local_roles.getRoles('group1'))
Beispiel #4
0
    def test_getRoles_1(self):
        """
        Expecting an empty list when no user or group roles attributes exist
        """
        class Dummy:
            pass

        obj = Dummy()
        local_roles = LocalRoles(obj)
        self.assertEqual([], local_roles.getRoles('dummy'))
 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()))
Beispiel #6
0
    def test_getRoles_5(self):
        """
        Expecting the list of roles when a group has roles assigned.
        """
        class Dummy:
            user_roles = None
            group_roles = {'group1': ['role1', 'role2']}

        obj = Dummy()
        local_roles = LocalRoles(obj)
        self.assertEqual(['role1', 'role2'], local_roles.getRoles('group1'))
Beispiel #7
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()))
 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_getRoles_2(self):
     """
     Expecting an empty list when the user and group roles attributes are
     None.
     """
     class Dummy:
         user_roles = None
         group_roles = None
     obj = Dummy()
     local_roles = LocalRoles(obj)
     self.assertEqual([], local_roles.getRoles('dummy'))
 def test_getRoles_3(self):
     """
     Expecting an empty list when the user and group roles attributes are
     empty dictionaries.
     """
     class Dummy:
         user_roles = {}
         group_roles = {}
     obj = Dummy()
     local_roles = LocalRoles(obj)
     self.assertEqual([], local_roles.getRoles('dummy'))
 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()))
Beispiel #12
0
    def test_getRoles_2(self):
        """
        Expecting an empty list when the user and group roles attributes are
        None.
        """
        class Dummy:
            user_roles = None
            group_roles = None

        obj = Dummy()
        local_roles = LocalRoles(obj)
        self.assertEqual([], local_roles.getRoles('dummy'))
Beispiel #13
0
    def test_getRoles_3(self):
        """
        Expecting an empty list when the user and group roles attributes are
        empty dictionaries.
        """
        class Dummy:
            user_roles = {}
            group_roles = {}

        obj = Dummy()
        local_roles = LocalRoles(obj)
        self.assertEqual([], local_roles.getRoles('dummy'))
Beispiel #14
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()))
Beispiel #15
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()))
Beispiel #16
0
    def test_getRoles_4(self):
        """
        Expecting the list of roles when a user has roles assigned.
        """
        class Dummy:
            user_roles = {
                'user1': ['role1'],
            }
            group_roles = None

        obj = Dummy()
        local_roles = LocalRoles(obj)
        self.assertEqual(['role1'], local_roles.getRoles('user1'))
 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)
Beispiel #18
0
    def test___init__(self):
        class Dummy:
            pass

        obj = Dummy()
        local_roles = LocalRoles(obj)
        self.failUnless(local_roles.context == obj)
Beispiel #19
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)