Exemplo 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)
Exemplo 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)