当前位置: 首页>>代码示例>>Python>>正文


Python project.Project类代码示例

本文整理汇总了Python中app.models.project.Project的典型用法代码示例。如果您正苦于以下问题:Python Project类的具体用法?Python Project怎么用?Python Project使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_project_show_delete

    def test_project_show_delete(self, mock_os):
        """Test file deletion.
        """
        mock_os.path.isdir.return_value = False

        project = Project(name="test")
        db.session.add(project)
        self.user.add_project(project, role=ProjectsUsers.ROLE_ADMIN)
        project.save()
        pid = str(project.id)

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

        result = self.client.post(application.config["DELETE_ROUTE"], data={
            "project_id": pid,
            "obj_type": "doc",
            "obj_id": document_file1.id
            })

        assert '"obj_type": "doc",' in result.data
        assert '"obj_id": %s' % document_file1.id in result.data 
        mock_os.remove.assert_any_call("/test-path/1.xml")
        # mock_os.remove.assert_any_call("/test-path/2.xml")
        assert mock_os.remove.call_count == 1
开发者ID:Wordseer,项目名称:wordseer,代码行数:30,代码来源:testuploader.py

示例2: test_project_show_bad_process

    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()
开发者ID:xiaobaozi34,项目名称:wordseer,代码行数:30,代码来源:testuploader.py

示例3: test_project_show_upload

    def test_project_show_upload(self):
        """Try uploading a file to the project_show view.
        """

        project = Project(name="test")
        db.session.add(project)
        self.user.add_project(project, role=ProjectsUsers.ROLE_ADMIN)
        project.save()

        pid = str(project.id)

        upload_dir = tempfile.mkdtemp()
        application.config["UPLOAD_DIR"] = upload_dir
        os.makedirs(os.path.join(upload_dir, pid))

        result = self.client.post(application.config["PROJECT_ROUTE"] + pid + "/upload", data={
            "uploaded_file": (StringIO("<thing>Test file</thing>"), "test.xml")
            })

        data = loads(result.data)
        # validation error contains "The file test.xml is not well-formed XML."
        assert os.path.exists(os.path.join(upload_dir, pid, "test.xml"))
        assert data["files"][0]["type"] == "doc"
        assert data["files"][0]["filename"] == "test.xml"

        uploaded_file = open(os.path.join(upload_dir, pid, "test.xml"))

        assert uploaded_file.read() == "<thing>Test file</thing>"
开发者ID:Wordseer,项目名称:wordseer,代码行数:28,代码来源:testuploader.py

示例4: test_projects

 def test_projects(self):
     """Test the projects view with a project present.
     """
     new_project = Project(name="test", user=self.user)
     new_project.save()
     result = self.client.get("/projects/")
     assert "/projects/1" in result.data
开发者ID:xiaobaozi34,项目名称:wordseer,代码行数:7,代码来源:testuploader.py

示例5: test_logs

    def test_logs(self):
        """Test to make sure that logs are being displayed.
        """

        project1 = Project(name="log test project", path="/log-test-path")
    
        self.user.add_project(project1, role=ProjectsUsers.ROLE_ADMIN)

        logs = [WarningLog(log_item="a", item_value="a", project=project1),
            InfoLog(log_item="b", item_value="b", project=project1),
            ErrorLog(log_item="c", item_value="c", project=project1)]

        project1.document_files = [DocumentFile(path="foo")]
        db.session.add(project1)
        db.session.commit()

        result = self.client.get(application.config["PROJECT_ROUTE"] + str(project1.id))

        print result.data
        assert "log test project" in result.data
        assert "processlog alert alert-warning" in result.data
        assert "processlog alert alert-warning hidden" not in result.data
        assert "processlog alert alert-info" in result.data
        assert "processlog alert alert-info hidden" not in result.data
        assert "processlog alert alert-danger" in result.data
        assert "processlog alert alert-danger hidden" not in result.data
        assert "<em>a</em>: a" in result.data
        assert "<em>b</em>: b" in result.data
        assert "<em>c</em>: c" in result.data
开发者ID:Wordseer,项目名称:wordseer,代码行数:29,代码来源:testuploader.py

示例6: after_put

 def after_put(self, instance):
     total_hours = instance.temp_alloc
     if instance.temp_type == 'minus':
         pass
     else:
         proj_params = Project.find_by_proj_key(instance.project_id)
         rem_hours = Project.removeHours(proj_params, total_hours)
         return rem_hours
开发者ID:Joeper214,项目名称:MoonHauz,代码行数:8,代码来源:allocbehavior.py

示例7: test_no_project_show

    def test_no_project_show(self):
        """Make sure project_show says that there are no files.
        """
        project = Project(name="test", users=[self.user])
        project.save()
        result = self.client.get(application.config["PROJECT_ROUTE"] + str(project.id))

        assert "test" in result.data
        assert "There are no Documents in this project." in result.data
开发者ID:Wordseer,项目名称:wordseer,代码行数:9,代码来源:testuploader.py

示例8: test_no_project_show

    def test_no_project_show(self):
        """Make sure project_show says that there are no files.
        """
        project = Project(name="test", user=self.user)
        project.save()
        result = self.client.get("/projects/1")

        assert "test" in result.data
        assert "There are no files in this project" in result.data
开发者ID:xiaobaozi34,项目名称:wordseer,代码行数:9,代码来源:testuploader.py

示例9: AuthTests

class AuthTests(unittest.TestCase):
    """Make sure that users can only see the pages and such that they
    should be seeing.
    """
    #TODO: can we make this a classmethod without SQLAlchemy complaining?
    def setUp(self):
        database.clean()
        self.client = application.test_client()
        self.user1 = user_datastore.create_user(email="[email protected]m",
            password="password")
        self.user2 = user_datastore.create_user(email="[email protected]",
            password="password")
        db.session.commit()
        with self.client.session_transaction() as sess:
            sess["user_id"] = self.user1.get_id()
            sess["_fresh"] = True

        self.project = Project(name="Bars project", user=self.user2)
        self.project.save()

        file_handle, file_path = tempfile.mkstemp()
        file_handle = os.fdopen(file_handle, "r+")
        file_handle.write("foobar")

        self.file_path = os.path.join(file_path)
        self.document_file = DocumentFile(projects=[self.project],
                path=self.file_path)
        self.document_file.save()

    def test_list_projects(self):
        """Test to make sure that bar's projects aren't listed for foo.
        """
        result = self.client.get("/projects/")

        assert "Bars project" not in result.data

    def test_view_project(self):
        """Test to make sure that foo can't see bar's project.
        """
        result = self.client.get("/projects/" + str(self.project.id))
        assert "Bars project" not in result.data

    def test_view_document(self):
        """Test to make sure that foo can't see bar's file.
        """
        result = self.client.get("/projects/" + str(self.project.id) +
            "/documents/" + str(self.document_file.id))

        assert "/uploads/" + str(self.document_file.id) not in result.data

    def test_get_document(self):
        """Test to make sure that foo can't get bar's file.
        """
        result = self.client.get("/uploads/" + str(self.document_file.id))

        with open(self.file_path) as test_file:
            assert result.data is not test_file.read()
开发者ID:xiaobaozi34,项目名称:wordseer,代码行数:57,代码来源:testuploader.py

示例10: setUpModule

def setUpModule():
    global project
    project = Project()
    project.save()
    global mock_project_logger
    with mock.patch("app.preprocessor.collectionprocessor.StringProcessor",
            autospec=True), mock.patch("app.preprocessor.collectionprocessor.logger.ProjectLogger",
            autospec=True):
        global colproc
        colproc = collectionprocessor.CollectionProcessor(project.id)
开发者ID:Wordseer,项目名称:wordseer,代码行数:10,代码来源:testcollectionprocessor.py

示例11: test_log

    def test_log(self):
        """Test the log() method. These tests assume that get() works.
        """
        project = Project()
        project.save()

        logger.log(project, "logtest", "true", logger.REPLACE)
        self.failUnless(logger.get(project, "logtest") == "true")

        logger.log(project, "logtest", "false", logger.UPDATE)
        self.failUnless(logger.get(project, "logtest") == "true [false] ")
开发者ID:Wordseer,项目名称:wordseer,代码行数:11,代码来源:testlogger.py

示例12: test_projects_bad_create

    def test_projects_bad_create(self):
        """Test creating an existing project.
        """
        project = Project(name="test", user=self.user)
        project.save()

        result = self.client.post("/projects/", data={
            "create-submitted": "true",
            "create-name": "test"
            })

        assert "already exists" in result.data
开发者ID:xiaobaozi34,项目名称:wordseer,代码行数:12,代码来源:testuploader.py

示例13: test_projects_duplicate_create

    def test_projects_duplicate_create(self):
        """Test creating a project with the same name as another user's.
        """
        project = Project(name="test", users=[User()])
        project.save()

        result = self.client.post("/projects/", data={
            "create-submitted": "true",
            "name": "test"
            })

        assert "already exists" not in result.data
开发者ID:Wordseer,项目名称:wordseer,代码行数:12,代码来源:testuploader.py

示例14: test_get

    def test_get(self):
        """Test the get() method.
        """
        project = Project()
        project.save()

        entry = Log(project=project, item_value="true", log_item="logtest")
        entry.save()

        self.failUnless(logger.get(project, "logtest") ==
            Log.query.filter(Log.log_item == "logtest").all()[0].item_value)

        self.failUnless(logger.get(project, "fakerandomname") == "")
开发者ID:Wordseer,项目名称:wordseer,代码行数:13,代码来源:testlogger.py

示例15: test_logs

    def test_logs(self):
        """Test to make sure that logs are being displayed.
        """

        project1 = Project(name="foo", path="/test-path",
            user=self.user)
        project2 = Project(name="foob", path="/foobar",
            user=self.user)

        logs = [WarningLog(log_item="a", item_value="a", project=project1),
            InfoLog(log_item="b", item_value="b", project=project1),
            ErrorLog(log_item="c", item_value="c", project=project1)]

        project1.document_files = [DocumentFile(path="foo")]
        project2.document_files = [DocumentFile(path="foo")]
        project1.save()
        project2.save()

        result = self.client.get("/projects/1")

        assert "alert alert-warning" in result.data
        assert "alert alert-info" in result.data
        assert "alert alert-danger" in result.data
        assert "<em>a</em>: a" in result.data
        assert "<em>b</em>: b" in result.data
        assert "<em>c</em>: c" in result.data
开发者ID:xiaobaozi34,项目名称:wordseer,代码行数:26,代码来源:testuploader.py


注:本文中的app.models.project.Project类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。