當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。