Ejemplo n.º 1
0
    def test_sync_permissions(self):
        """
        test the syncpermission
        """
        repo = create_repo(self.repo_name, self.repo_desc, self.user.id)

        # Get default permissions before wiping.
        admin = Group.objects.get(name=self.group_admin)
        self.check_group_permission(
            repo,
            admin,
            RepoPermission.administrator_permissions()
        )
        with patch.object(utils, 'roles_init_new_repo') as mock_method:
            mock_method.return_value = None
            utils.sync_groups_permissions()
        # Get default permissions after wiping.
        self.check_group_permission(
            repo,
            admin,
            []
        )
        # Restore permissions the first call of sync_groups_permissions
        # will not do anything because the permissions have been already wiped.
        utils.sync_groups_permissions()
        self.check_group_permission(
            repo,
            admin,
            RepoPermission.administrator_permissions()
        )
Ejemplo n.º 2
0
def my_callback(sender, **kwargs):
    """
    Signal handler to apply new permissions to repositories
    only in case the sender is learningresources.
    """
    # pylint: disable=protected-access
    if sender.name == Repository._meta.app_label:
        sync_groups_permissions()
Ejemplo n.º 3
0
def my_callback(sender, **kwargs):
    """
    Signal handler to apply new permissions to repositories
    only in case the sender is learningresources.
    """
    # pylint: disable=protected-access
    if sender.name == Repository._meta.app_label:
        sync_groups_permissions()
Ejemplo n.º 4
0
    def test_sync_permissions(self):
        """
        test the syncpermission
        """
        repo = create_repo(self.repo_name, self.repo_desc, self.user.id)

        # Get default permissions before wiping.
        admin = Group.objects.get(name=self.group_admin)
        self.check_group_permission(repo, admin, RepoPermission.administrator_permissions())
        with patch.object(utils, "roles_init_new_repo") as mock_method:
            mock_method.return_value = None
            utils.sync_groups_permissions()
        # Get default permissions after wiping.
        self.check_group_permission(repo, admin, [])
        # Restore permissions the first call of sync_groups_permissions
        # will not do anything because the permissions have been already wiped.
        utils.sync_groups_permissions()
        self.check_group_permission(repo, admin, RepoPermission.administrator_permissions())
Ejemplo n.º 5
0
 def handle(self, *args, **options):
     """Command handler"""
     sync_groups_permissions()