Exemplo n.º 1
0
    def test_upload(self):

        # Create a project
        resourceNames = {'projectname': 'project1'}
        svs.deleteProject(resourceNames)
        input = {'project': self.project1, 'overwrite': True}
        svs.createProject(resourceNames, input)

        resourceNames = {'projectname': 'project22'}
        svs.deleteProject(resourceNames)
        input = {'project': self.project1, 'overwrite': True}
        svs.createProject(resourceNames, input)

        resourceNames = {'projectname': 'project1', 'foldername': 'folder1'}
        response = svs.upload(resourceNames, self.uploadData)

        resourceNames = {'projectname': 'project22', 'foldername': 'folder22'}
        response = svs.upload(resourceNames,
                              self.uploadZip,
                              uploadType='zipfile')

        resourceNames = {
            'projectname': 'project1',
            'foldername': 'folder1',
            'filename': 'iris.R'
        }
        response = svs.upload(resourceNames, self.rSource, uploadType='file')

        self.assertTrue(True)
Exemplo n.º 2
0
    def test_getProject(self):

        resourceNames = {'projectname': 'project1'}
        input = {'project': self.project1, 'overwrite': True}
        svs.createProject(resourceNames, input)

        # Get the project document and check the response
        response = svs.getProject(resourceNames)
        self.assertTrue(response.get('succeeded', True))
        project = response.get('project', None)
        self.assertTrue(project)
        self.assertEqual(project.get('projectName', None), 'project1')
Exemplo n.º 3
0
    def test_deleteProject(self):

        resourceNames = {'projectname': 'project1'}
        input = {'project': self.project1, 'overwrite': True}

        svs.createProject(resourceNames, input)
        projectPath = svs.getProjectsPath() + '/project1'
        self.assertTrue(os.path.isdir(projectPath))
        self.assertTrue(os.path.isfile(projectPath + '/project.json'))

        # Now try to delete it
        svs.deleteProject(resourceNames)
        self.assertFalse(os.path.isdir(projectPath))
        self.assertFalse(os.path.isfile(projectPath + '/project.json'))
Exemplo n.º 4
0
    def test_getProjects(self):

        # Create some projects
        resourceNames = {'projectname': 'project1'}
        input = {'project': self.project1, 'overwrite': True}
        svs.createProject(resourceNames, input)
        resourceNames = {'projectname': 'project2'}
        input = {'project': self.project2, 'overwrite': True}
        svs.createProject(resourceNames, input)

        # Get the projects collection and check the response
        response = svs.getProjects()
        self.assertTrue(response.get('succeeded', True))
        projects = response.get('projects', None)
        self.assertTrue(projects)
        project1 = projects.get('project1', None)
        project2 = projects.get('project2', None)
        self.assertTrue(project1)
        self.assertTrue(project2)
Exemplo n.º 5
0
    def test_createProject(self):

        resourceNames = {'projectname': 'project1'}
        svs.deleteProject(resourceNames)

        # Try to create a project
        input = {'project': self.project1, 'overwrite': False}
        response = svs.createProject(resourceNames, input)
        self.assertTrue(response.get('succeeded', False))

        # Check that overwrite flag works when set to false
        input = {'project': self.project1, 'overwrite': False}
        response = svs.createProject(resourceNames, input)
        self.assertFalse(response.get('succeeded', False))

        # Check that overwrite flag works when set to true
        input = {'project': self.project1, 'overwrite': True}
        response = svs.createProject(resourceNames, input)
        self.assertTrue(response.get('succeeded', False))
Exemplo n.º 6
0
    def test_updateProject(self):

        # Create a project
        resourceNames = {'projectname': 'project1'}
        input = {'project': self.project1, 'overwrite': True}
        response = svs.createProject(resourceNames, input)

        # Try updating the project.json file
        input = {'project': self.project3}
        response = svs.updateProject(resourceNames, input)
        newProject = response.get('project')
        self.assertTrue('Modified' in newProject.get('projectTitle'))
Exemplo n.º 7
0
    def test_deleteFolder(self):

        # Create a project
        resourceNames = {'projectname': 'project2'}
        input = {'project': self.project2, 'overwrite': True}
        svs.createProject(resourceNames, input)

        # Create some folders in the project directory
        projectPath = svs.getProjectsPath() + '/project2'
        os.mkdir(projectPath + '/' + 'folder1')
        os.mkdir(projectPath + '/' + 'folder2')

        # Try deleting a folder and check the results
        resourceNames = {'projectname': 'project2', 'foldername': 'folder2'}
        response = svs.deleteFolder(resourceNames)
        newproject = response.get('project')
        self.assertTrue(os.path.isdir(projectPath + '/' + 'folder1'))
        self.assertFalse(os.path.isdir(projectPath + '/' + 'folder2'))
        folders = newproject.get('folders', None)
        self.assertTrue(folders.get('folder1', None))
        self.assertFalse(folders.get('folder2', None))
Exemplo n.º 8
0
    def test_renameProject(self):

        resourceNames = {'projectname': 'project11'}
        svs.deleteProject(resourceNames)

        # Create a project
        resourceNames = {'projectname': 'project1'}
        input = {'project': self.project1, 'overwrite': True}
        response = svs.createProject(resourceNames, input)

        # Try to rename the project and check the results
        input = {"oldProjectName": 'project1', "newProjectName": 'project11'}
        response = svs.renameProject(input)
        newProject = response.get('project')
        self.assertTrue(newProject.get('projectName', None) == 'project11')
        oldProjectPath = svs.projectsPath + '/' + self.project1.get(
            'projectName', None)
        newProjectPath = svs.projectsPath + '/project11'
        self.assertFalse(os.path.isdir(oldProjectPath))
        self.assertTrue(os.path.isdir(newProjectPath))