Ejemplo n.º 1
0
    def test_merge_workspaces(self):

        workspace = Workspace.objects.get(pk=1)

        packageCloner = PackageCloner()
        cloned_workspace = packageCloner.clone_tuple(workspace)
        linkWorkspace(self.user, cloned_workspace.id, self.user)

        packageCloner = PackageCloner()
        packageCloner.merge_workspaces(cloned_workspace, workspace, self.user)

        # Check cache invalidation
        data = json.loads(get_global_workspace_data(workspace, self.user).get_data())
        tab_list = data['tabs']

        self.assertEqual(len(tab_list), 2)
Ejemplo n.º 2
0
    def test_clone_workspace(self):

        workspace = Workspace.objects.get(pk=1)

        packageCloner = PackageCloner()
        cloned_workspace = packageCloner.clone_tuple(workspace)

        self.assertNotEqual(workspace, cloned_workspace)
        self.assertEqual(cloned_workspace.users.count(), 0)

        original_iwidgets = IWidget.objects.filter(tab__workspace=workspace)
        cloned_iwidgets = IWidget.objects.filter(tab__workspace=cloned_workspace)
        self.assertEqual(original_iwidgets.count(), cloned_iwidgets.count())
        self.assertNotEqual(original_iwidgets[0].id, cloned_iwidgets[0].id)

        original_variables = Variable.objects.filter(iwidget__tab__workspace=workspace)
        cloned_variables = Variable.objects.filter(iwidget__tab__workspace=cloned_workspace)

        self.assertEqual(original_variables.count(), cloned_variables.count())
        self.assertNotEqual(original_variables[0].id, cloned_variables[0].id)
Ejemplo n.º 3
0
                check_mashup_dependencies(template, request.user)
            except MissingDependencies, e:
                details = {
                    'missingDependencies': e.missing_dependencies,
                }
                return build_error_response(request, 422, unicode(e), details=details)

            fillWorkspaceUsingTemplate(to_ws, template)

        else:

            from_ws = get_object_or_404(Workspace, id=workspace_id)
            if not request.user.is_superuser and from_ws.creator != request.user:
                return HttpResponseForbidden()

            packageCloner = PackageCloner()
            packageCloner.merge_workspaces(from_ws, to_ws, to_ws.creator)

        return HttpResponse(status=204)


def check_json_fields(json, fields):
    missing_fields = []

    for field in fields:
        if not field in json:
            missing_fields.append(field)

    return missing_fields