def test_get_object_users_with_permission(self):
        alice = self._create_user('alice', 'alice')
        org_user = tools.create_organization("modilabs", alice).user
        self._publish_transportation_form()
        EditorRole.add(org_user, self.xform)

        users_with_perms = get_object_users_with_permissions(self.xform)
        self.assertFalse(org_user in [d['user'] for d in users_with_perms])
Exemple #2
0
    def test_get_object_users_with_permission(self):
        alice = self._create_user('alice', 'alice')
        org_user = tools.create_organization("modilabs", alice).user
        self._publish_transportation_form()
        EditorRole.add(org_user, self.xform)

        users_with_perms = get_object_users_with_permissions(self.xform)
        self.assertFalse(org_user in [d['user'] for d in users_with_perms])
Exemple #3
0
    def test_create_organization_team(self):
        profile = tools.create_organization("modilabs", self.user)
        organization = profile.user
        team_name = 'dev'
        perms = ['is_org_owner', ]
        tools.create_organization_team(organization, team_name, perms)
        team_name = "modilabs#%s" % team_name
        dev_team = Team.objects.get(organization=organization, name=team_name)

        self.assertIsInstance(dev_team, Team)
        self.assertIsInstance(
            dev_team.permissions.get(codename='is_org_owner'), Permission)
    def test_disallow_same_username_with_different_cases(self):
        tools.create_organization("modilabs", self.user)
        with self.assertRaises(IntegrityError):
            tools.create_organization("ModiLabs", self.user)

        # test disallow org create with same username same cases
        with self.assertRaises(IntegrityError):
            tools.create_organization("modiLabs", self.user)
Exemple #5
0
 def test_get_object_users_with_permission(self):
     alice = self._create_user('alice', 'alice')
     org_user = tools.create_organization("modilabs", alice).user
     self._publish_transportation_form()
     EditorRole.add(org_user, self.xform)
     users_with_perms = get_object_users_with_permissions(self.xform)
     self.assertTrue(org_user in [d['user'] for d in users_with_perms])
     self.assertIn('first_name', users_with_perms[0].keys())
     self.assertIn('last_name', users_with_perms[0].keys())
     self.assertIn('user', users_with_perms[0].keys())
     self.assertIn('role', users_with_perms[0].keys())
     self.assertIn('gravatar', users_with_perms[0].keys())
     self.assertIn('metadata', users_with_perms[0].keys())
     self.assertIn('is_org', users_with_perms[0].keys())
    def test_create_organization_creates_team_and_perms(self):
        # create a user - bob
        profile = tools.create_organization("modilabs", self.user)
        self.assertIsInstance(profile, OrganizationProfile)
        organization_profile = OrganizationProfile.objects.get(
            user__username="******")

        # check organization was created
        self.assertTrue(organization_profile.is_organization)

        # check that the default team was created
        team_name = "modilabs#%s" % Team.OWNER_TEAM_NAME
        team = Team.objects.get(
            organization=organization_profile.user, name=team_name)
        self.assertIsInstance(team, Team)
        self.assertIn(team.group_ptr, self.user.groups.all())
        self.assertTrue(self.user.has_perm('api.is_org_owner'))
    def test_create_organization_creates_team_and_perms(self):
        # create a user - bob
        profile = tools.create_organization("modilabs", self.user)
        self.assertIsInstance(profile, OrganizationProfile)
        organization_profile = OrganizationProfile.objects.get(
            user__username="******")

        # check organization was created
        self.assertTrue(organization_profile.is_organization)

        # check that the default team was created
        team_name = "modilabs#%s" % Team.OWNER_TEAM_NAME
        team = Team.objects.get(organization=organization_profile.user,
                                name=team_name)
        self.assertIsInstance(team, Team)
        self.assertIn(team.group_ptr, self.user.groups.all())
        self.assertTrue(self.user.has_perm('api.is_org_owner'))
Exemple #8
0
 def test_get_object_users_with_permission(self):
     """
     Test get_object_users_with_permissions()
     """
     alice = self._create_user('alice', 'alice')
     UserProfile.objects.get_or_create(user=alice)
     org_user = tools.create_organization("modilabs", alice).user
     demo_grp = Group.objects.create(name='demo')
     alice.groups.add(demo_grp)
     self._publish_transportation_form()
     EditorRole.add(org_user, self.xform)
     EditorRole.add(demo_grp, self.xform)
     users_with_perms = get_object_users_with_permissions(
         self.xform, with_group_users=True)
     self.assertTrue(org_user in [d['user'] for d in users_with_perms])
     self.assertTrue(alice in [d['user'] for d in users_with_perms])
     users_with_perms_first_keys = list(users_with_perms[0])
     self.assertIn('first_name', users_with_perms_first_keys)
     self.assertIn('last_name', users_with_perms_first_keys)
     self.assertIn('user', users_with_perms_first_keys)
     self.assertIn('role', users_with_perms_first_keys)
     self.assertIn('gravatar', users_with_perms_first_keys)
     self.assertIn('metadata', users_with_perms_first_keys)
     self.assertIn('is_org', users_with_perms_first_keys)
 def test_disallow_same_username_with_different_cases(self):
     tools.create_organization("modilabs", self.user)
     with self.assertRaises(IntegrityError):
         tools.create_organization("ModiLabs", self.user)
 def test_disallow_same_username_with_different_cases(self):
     tools.create_organization("modilabs", self.user)
     with self.assertRaises(ValidationError):
         tools.create_organization("ModiLabs", self.user)
 def _create_organization(self, org_name, user):
     profile = tools.create_organization(org_name, user)
     self.organization = profile.user
     return self.organization