Exemplo n.º 1
0
    def test_if_region_is_granted_or_not(self):
        nld_region = utils.RegionFactory(name='NLD')
        user_profile = utils.UserFactory().get_profile()

        self.assertFalse(user_profile.is_region_granted(nld_region))
        user_profile.region_set.add(nld_region)
        self.assertTrue(user_profile.is_region_granted(nld_region))
Exemplo n.º 2
0
 def test_manager_country_attribute_populate_country(self):
     ldap_attr = 'c'
     override_settings = {'country': ldap_attr}
     user = utils.UserFactory()
     user_profile = user.get_profile()
     faked_ldap_user = self._get_mocked_ldap_user({ldap_attr: ['XXX']})
     with self.settings(AUTH_LDAP_PROFILE_ATTR_MAP=override_settings):
         manager_country_attribute_populate(None, user_profile,
                                            faked_ldap_user)
         self.assertEqual(user_profile.country, None)
Exemplo n.º 3
0
    def test_getting_regions(self):
        user = utils.UserFactory()
        user_profile = user.get_profile()
        default_region = Region.objects.get(name=settings.DEFAULT_REGION_NAME)

        self.assertEqual(len(user_profile.get_regions()), 1)
        self.assertEqual(user_profile.get_regions()[0], default_region)

        nld_region = utils.RegionFactory(name='NLD')
        user_profile.region_set.add(nld_region)
        self.assertEqual(len(user_profile.get_regions()), 1)
        self.assertEqual(user_profile.get_regions()[0], nld_region)
Exemplo n.º 4
0
    def test_manager_country_attribute_populate_unicode_in_manager(self):
        ldap_attr = 'manager'
        override_settings = {'manager': ldap_attr}
        manager_names = [unicode('Żółcień'), str('John Smith')]
        user = utils.UserFactory()
        user_profile = user.get_profile()

        for manager_name in manager_names:
            faked_ldap_user = self._get_mocked_ldap_user(
                {ldap_attr: ['CN={},OU=XXX,DC=group'.format(manager_name)]})

            with self.settings(AUTH_LDAP_PROFILE_ATTR_MAP=override_settings):
                manager_country_attribute_populate(None, user_profile,
                                                   faked_ldap_user)
            self.assertEqual(user_profile.manager, manager_name)
            self.assertTrue(isinstance(user_profile.manager, unicode))