Exemplo n.º 1
0
    def test_project_show_bad_process(self, mock_process_files):
        """Test processing an unprocessable group of files.
        """
        project = Project(name="test", user=self.user, path="/foo")
        project.save()

        document_file1 = DocumentFile(projects=[project],
            path="/test-path/1.xml")
        document_file2 = DocumentFile(projects=[project],
            path="/test-path/2.xml")
        document_file1.save()
        document_file2.save()

        result = self.client.post("/projects/1", data={
            "process-submitted": "true",
            "action": "0",
            "process-selection": ["1", "2"]
            })

        assert "must include exactly one" in result.data

        structure_file = StructureFile(project=project, path="/foo/bar.json")
        structure_file.save()

        result = self.client.post("/projects/1", data={
            "process-submitted": "true",
            "action": "0",
            "process-structure_file": [str(structure_file.id)]
            })
        assert "at least one document" in result.data.lower()
Exemplo n.º 2
0
    def test_process_processed_files(self):
        """Make sure that a project that's being processed or already
        processed can't be processed again.
        """

        project1 = Project(name="foo",
                           path="/test-path",
                           status=Project.STATUS_PREPROCESSING)
        rel = self.user.add_project(project1, role=ProjectsUsers.ROLE_ADMIN)
        document_file = DocumentFile(path="foo/foo.xml")
        structure_file = StructureFile(path="foo/foo.json")
        project1.document_files = [document_file]
        project1.structure_files = [structure_file]
        project1.save()

        data = {
            "struc_id": structure_file.id,
        }

        result = self.client.post(application.config["PROCESS_ROUTE"] +
                                  str(project1.id),
                                  data=data)

        assert '"status": "OK"' not in result.data

        project1.status = Project.STATUS_DONE
        project1.save()

        result = self.client.post(application.config["PROCESS_ROUTE"] +
                                  str(project1.id),
                                  data=data)

        assert '"status": "OK"' not in result.data
Exemplo n.º 3
0
    def test_project_show_process_no_perms(self):
        """Process files without proper permissions.
        """
        project = Project(name="foo")
        rel = self.user.add_project(project, role=ProjectsUsers.ROLE_USER)
        document_file = DocumentFile(projects=[project], path="/foo/bar.xml")
        structure_file = StructureFile(project=project, path="/foo/bar.json")
        document_file.save()
        structure_file.save()
        project.save()

        result = self.client.post("/projects/1", data={
            "process-submitted": "true",
            "action": "0",
            "process-selection": [str(document_file.id)],
            "process-structure_file": str(structure_file.id)
            })

        assert "You can't do that" in result.data
Exemplo n.º 4
0
    def test_project_show_process_no_perms(self):
        """Process files without proper permissions.
        """
        project = Project(name="foo")
        rel = self.user.add_project(project, role=ProjectsUsers.ROLE_USER)
        document_file = DocumentFile(projects=[project], path="/foo/bar.xml")
        structure_file = StructureFile(project=project, path="/foo/bar.json")
        document_file.save()
        structure_file.save()
        project.save()

        result = self.client.post("/projects/1",
                                  data={
                                      "process-submitted":
                                      "true",
                                      "action":
                                      "0",
                                      "process-selection":
                                      [str(document_file.id)],
                                      "process-structure_file":
                                      str(structure_file.id)
                                  })

        assert "You can't do that" in result.data
Exemplo n.º 5
0
    def test_project_show_process_no_perms(self):
        """Delete files without proper permissions.
        """
        project = Project(name="foo")
        rel = self.user.add_project(project, role=ProjectsUsers.ROLE_USER)
        document_file1 = DocumentFile(projects=[project], path="/foo/bar.xml")
        structure_file1 = StructureFile(project=project, path="/foo/bar.json")
        project.save()

        result = self.client.post("/projects/1",
                                  data={
                                      "process-submitted": "true",
                                      "action": "-1",
                                      "process-selection": ["1"]
                                  })

        assert '"status": "OK",' not in result.data