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


Python Fixtures.create方法代码示例

本文整理汇总了Python中base.Fixtures.create方法的典型用法代码示例。如果您正苦于以下问题:Python Fixtures.create方法的具体用法?Python Fixtures.create怎么用?Python Fixtures.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在base.Fixtures的用法示例。


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

示例1: test_22_get_specific_completed_task_anonymous

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_22_get_specific_completed_task_anonymous(self):
        """Test WEB get specific completed task_id for an app works as anonymous"""

        model.rebuild_db()
        Fixtures.create()
        app = model.Session.query(model.App).first()
        task = model.Session.query(model.Task)\
                .filter(model.App.id==app.id)\
                .first()

        for i in range(10):
            task_run = model.TaskRun(app_id=app.id,
                    task_id=task.id,
                    user_ip="127.0.0.1",
                    info={'answer':1})
            model.Session.add(task_run)
            model.Session.commit()


        ntask = model.Task(id=task.id,state='completed')

        assert ntask not in model.Session
        model.Session.merge(ntask)
        model.Session.commit()

        res = self.app.get('app/%s/task/%s' % (app.short_name, task.id),
                follow_redirects=True)
        assert 'You have already participated in this task' in res.data, res.data
        assert 'Try with another one' in res.data, res.data
开发者ID:Renalves,项目名称:pybossa,代码行数:31,代码来源:test_web.py

示例2: test_24_get_specific_completed_task_user

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_24_get_specific_completed_task_user(self):
        """Test WEB get specific completed task_id for an app works as an user"""

        model.rebuild_db()
        Fixtures.create()
        self.register()

        user = model.Session.query(model.User)\
                .filter(model.User.name=='johndoe')\
                .first()
        app = model.Session.query(model.App).first()
        task = model.Session.query(model.Task)\
                .filter(model.App.id==app.id)\
                .first()
        for i in range(10):
            task_run = model.TaskRun(app_id=app.id,
                    task_id=task.id,
                    user_id=user.id,
                    info={'answer':1})
            model.Session.add(task_run)
            model.Session.commit()
            #self.app.get('api/app/%s/newtask' % app.id)

        ntask = model.Task(id=task.id,state='completed')
        #self.signin()
        assert ntask not in model.Session
        model.Session.merge(ntask)
        model.Session.commit()

        res = self.app.get('app/%s/task/%s' % (app.short_name, task.id),
                follow_redirects=True)
        assert 'You have already participated in this task' in res.data, res.data
        assert 'Try with another one' in res.data, res.data
        self.signout()
开发者ID:Renalves,项目名称:pybossa,代码行数:36,代码来源:test_web.py

示例3: test_20_admin_add_category

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_20_admin_add_category(self):
        """Test ADMIN add category works"""
        Fixtures.create()
        category = {"name": "cat", "short_name": "cat", "description": "description"}
        # Anonymous user
        url = "/admin/categories"
        res = self.app.post(url, data=category, follow_redirects=True)
        dom = BeautifulSoup(res.data)
        err_msg = "Anonymous users should be redirected to sign in"
        assert dom.find(id="signin") is not None, err_msg

        # Authenticated user but not admin
        self.signin(email=Fixtures.email_addr2, password=Fixtures.password)
        res = self.app.post(url, data=category, follow_redirects=True)
        err_msg = "Non-Admin users should get 403"
        assert res.status_code == 403, err_msg
        self.signout()

        # Admin
        self.signin(email=Fixtures.root_addr, password=Fixtures.root_password)
        res = self.app.post(url, data=category, follow_redirects=True)
        err_msg = "Category should be added"
        assert "Category added" in res.data, err_msg
        assert category["name"] in res.data, err_msg

        category = {"name": "cat", "short_name": "cat", "description": "description"}

        self.signin(email=Fixtures.root_addr, password=Fixtures.root_password)
        res = self.app.post(url, data=category, follow_redirects=True)
        err_msg = "Category form validation should work"
        assert "Please correct the errors" in res.data, err_msg
开发者ID:nmashton,项目名称:pybossa,代码行数:33,代码来源:test_admin.py

示例4: test_20_admin_add_category

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_20_admin_add_category(self):
        """Test ADMIN add category works"""
        Fixtures.create()
        category = {'name': 'cat', 'short_name': 'cat',
                    'description': 'description'}
        # Anonymous user
        url = '/admin/categories'
        res = self.app.post(url, data=category, follow_redirects=True)
        dom = BeautifulSoup(res.data)
        err_msg = "Anonymous users should be redirected to sign in"
        assert dom.find(id='signin') is not None, err_msg

        # Authenticated user but not admin
        self.signin(email=Fixtures.email_addr2, password=Fixtures.password)
        res = self.app.post(url, data=category, follow_redirects=True)
        err_msg = "Non-Admin users should get 403"
        assert res.status_code == 403, err_msg
        self.signout()

        # Admin
        self.signin(email=Fixtures.root_addr, password=Fixtures.root_password)
        res = self.app.post(url, data=category, follow_redirects=True)
        err_msg = "Category should be added"
        assert "Category added" in res.data, err_msg
        assert category['name'] in res.data, err_msg
开发者ID:ferryville,项目名称:pybossa,代码行数:27,代码来源:test_admin.py

示例5: test_25_get_wrong_task_app

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_25_get_wrong_task_app(self):
        """Test WEB get wrong task.id for an app works"""

        model.rebuild_db()
        Fixtures.create()
        app1 = db.session.query(model.App).get(1)
        app1_short_name = app1.short_name

        db.session.query(model.Task)\
                .filter(model.Task.app_id == 1)\
                .first()

        self.register()
        self.new_application()
        app2 = db.session.query(model.App).get(2)
        self.new_task(app2.id)
        task2 = db.session.query(model.Task)\
                .filter(model.Task.app_id == 2)\
                .first()
        task2_id = task2.id
        self.signout()

        res = self.app.get('/app/%s/task/%s' % (app1_short_name, task2_id))
        assert "Error" in res.data, res.data
        assert "This task does not belong to %s" % app1_short_name\
                in res.data, res.data
开发者ID:jcooley,项目名称:pybossa,代码行数:28,代码来源:test_web.py

示例6: test_22_admin_delete_category

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_22_admin_delete_category(self):
        """Test ADMIN delete category works"""
        Fixtures.create()
        obj = db.session.query(model.Category).get(2)
        category = obj.dictize()

        # Anonymous user GET
        url = "/admin/categories/del/%s" % obj.id
        res = self.app.get(url, follow_redirects=True)
        dom = BeautifulSoup(res.data)
        err_msg = "Anonymous users should be redirected to sign in"
        assert dom.find(id="signin") is not None, err_msg
        # Anonymous user POST
        res = self.app.post(url, data=category, follow_redirects=True)
        dom = BeautifulSoup(res.data)
        err_msg = "Anonymous users should be redirected to sign in"
        assert dom.find(id="signin") is not None, err_msg

        # Authenticated user but not admin GET
        self.signin(email=Fixtures.email_addr2, password=Fixtures.password)
        res = self.app.post(url, follow_redirects=True)
        err_msg = "Non-Admin users should get 403"
        assert res.status_code == 403, err_msg
        # Authenticated user but not admin POST
        res = self.app.post(url, data=category, follow_redirects=True)
        err_msg = "Non-Admin users should get 403"
        assert res.status_code == 403, err_msg
        self.signout()

        # Admin GET
        self.signin(email=Fixtures.root_addr, password=Fixtures.root_password)
        res = self.app.get(url, follow_redirects=True)
        err_msg = "Category should be listed for admin user"
        assert category["name"] in res.data, err_msg
        # Admin POST
        res = self.app.post(url, data=category, follow_redirects=True)
        err_msg = "Category should be deleted"
        assert "Category deleted" in res.data, err_msg
        assert category["name"] not in res.data, err_msg
        output = db.session.query(model.Category).get(obj.id)
        assert output is None, err_msg
        # Non existant category
        category["id"] = 5000
        url = "/admin/categories/del/5000"
        res = self.app.post(url, data=category, follow_redirects=True)
        assert res.status_code == 404, res.status_code

        # Now try to delete the only available Category
        obj = db.session.query(model.Category).first()
        url = "/admin/categories/del/%s" % obj.id
        category = obj.dictize()
        res = self.app.post(url, data=category, follow_redirects=True)
        print res.data
        err_msg = "Category should not be deleted"
        assert "Category deleted" not in res.data, err_msg
        assert category["name"] in res.data, err_msg
        output = db.session.query(model.Category).get(obj.id)
        assert output.id == category["id"], err_msg
开发者ID:nmashton,项目名称:pybossa,代码行数:60,代码来源:test_admin.py

示例7: test_21_get_specific_ongoing_task_anonymous

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_21_get_specific_ongoing_task_anonymous(self):
        """Test WEB get specific ongoing task_id for
        an app works as anonymous"""

        Fixtures.create()
        self.delTaskRuns()
        app = db.session.query(model.App).first()
        task = db.session.query(model.Task).filter(model.App.id == app.id).first()
        res = self.app.get("app/%s/task/%s" % (app.short_name, task.id), follow_redirects=True)
        assert "TaskPresenter" in res.data, res.data
        assert "?next=%2Fapp%2F" + app.short_name + "%2Ftask%2F" + str(task.id), res.data
开发者ID:stefanw,项目名称:pybossa,代码行数:13,代码来源:test_web.py

示例8: test_29_tutorial_anonymous_user

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
 def test_29_tutorial_anonymous_user(self):
     """Test WEB app without tutorials work as an anonymous user"""
     Fixtures.create()
     db.session.commit()
     self.register()
     # First time accessing the app should redirect me to the tutorial
     res = self.app.get("/app/test-app/newtask", follow_redirects=True)
     assert "some help" not in res.data, "There should not be a tutorial for the application"
     # Second time should give me a task, and not the tutorial
     res = self.app.get("/app/test-app/newtask", follow_redirects=True)
     assert "some help" not in res.data
开发者ID:stefanw,项目名称:pybossa,代码行数:13,代码来源:test_web.py

示例9: test_28_non_tutorial_signed_user

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
 def test_28_non_tutorial_signed_user(self):
     """Test WEB app without tutorial work as signed in user"""
     Fixtures.create()
     model.Session.commit()
     self.register()
     # First time accessing the app should redirect me to the tutorial
     res = self.app.get('/app/test-app/newtask', follow_redirects=True)
     assert "some help" not in res.data,\
             "There should not be a tutorial for the application"
     # Second time should give me a task, and not the tutorial
     res = self.app.get('/app/test-app/newtask', follow_redirects=True)
     assert "some help" not in res.data
开发者ID:steko,项目名称:pybossa,代码行数:14,代码来源:test_web.py

示例10: test_21_get_specific_ongoing_task_anonymous

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_21_get_specific_ongoing_task_anonymous(self):
        """Test WEB get specific ongoing task_id for an app works as anonymous"""

        Fixtures.create()
        self.delTaskRuns()
        app = model.Session.query(model.App).first()
        task = model.Session.query(model.Task)\
                .filter(model.App.id==app.id)\
                .first()
        res = self.app.get('app/%s/task/%s' % (app.short_name, task.id),
                follow_redirects=True)
        assert 'TaskPresenter' in res.data, res.data
开发者ID:Renalves,项目名称:pybossa,代码行数:14,代码来源:test_web.py

示例11: test_23_get_specific_ongoing_task_user

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_23_get_specific_ongoing_task_user(self):
        """Test WEB get specific ongoing task_id for an app works as an user"""

        Fixtures.create()
        self.delTaskRuns()
        self.register()
        self.signin()
        app = db.session.query(model.App).first()
        task = db.session.query(model.Task).filter(model.App.id == app.id).first()
        res = self.app.get("app/%s/task/%s" % (app.short_name, task.id), follow_redirects=True)
        assert "TaskPresenter" in res.data, res.data
        self.signout()
开发者ID:stefanw,项目名称:pybossa,代码行数:14,代码来源:test_web.py

示例12: test_26_tutorial_signed_user

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
 def test_26_tutorial_signed_user(self):
     """Test WEB tutorials work as signed in user"""
     Fixtures.create()
     app1 = db.session.query(model.App).get(1)
     app1.info = dict(tutorial="some help")
     db.session.commit()
     self.register()
     # First time accessing the app should redirect me to the tutorial
     res = self.app.get("/app/test-app/newtask", follow_redirects=True)
     assert "some help" in res.data, "There should be some tutorial for the application"
     # Second time should give me a task, and not the tutorial
     res = self.app.get("/app/test-app/newtask", follow_redirects=True)
     assert "some help" not in res.data
开发者ID:stefanw,项目名称:pybossa,代码行数:15,代码来源:test_web.py

示例13: test_06_featured_apps

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_06_featured_apps(self):
        """Test WEB application index shows featured apps in all the pages works"""
        Fixtures.create()

        f = model.Featured()
        f.app_id=1
        db.session.add(f)
        db.session.commit()

        res = self.app.get('/app', follow_redirects=True)
        assert self.html_title("Applications") in res.data, res.data
        assert "Applications" in res.data, res.data
        assert '/app/test-app' in res.data, res.data
        assert '<h2> <i class="icon-star"></i><a href="/app/test-app">My New App</a></h2>' in res.data, res.data
开发者ID:DO101,项目名称:pybossa,代码行数:16,代码来源:test_web.py

示例14: test_21_admin_update_category

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
    def test_21_admin_update_category(self):
        """Test ADMIN update category works"""
        Fixtures.create()
        obj = db.session.query(model.Category).get(1)
        _name = obj.name
        category = obj.dictize()

        # Anonymous user GET
        url = "/admin/categories/update/%s" % obj.id
        res = self.app.get(url, follow_redirects=True)
        dom = BeautifulSoup(res.data)
        err_msg = "Anonymous users should be redirected to sign in"
        assert dom.find(id="signin") is not None, err_msg
        # Anonymous user POST
        res = self.app.post(url, data=category, follow_redirects=True)
        dom = BeautifulSoup(res.data)
        err_msg = "Anonymous users should be redirected to sign in"
        assert dom.find(id="signin") is not None, err_msg

        # Authenticated user but not admin GET
        self.signin(email=Fixtures.email_addr2, password=Fixtures.password)
        res = self.app.post(url, follow_redirects=True)
        err_msg = "Non-Admin users should get 403"
        assert res.status_code == 403, err_msg
        # Authenticated user but not admin POST
        res = self.app.post(url, data=category, follow_redirects=True)
        err_msg = "Non-Admin users should get 403"
        assert res.status_code == 403, err_msg
        self.signout()

        # Admin GET
        self.signin(email=Fixtures.root_addr, password=Fixtures.root_password)
        res = self.app.get(url, follow_redirects=True)
        err_msg = "Category should be listed for admin user"
        assert _name in res.data, err_msg
        # Check 404
        url_404 = "/admin/categories/update/5000"
        res = self.app.get(url_404, follow_redirects=True)
        assert res.status_code == 404, res.status_code
        # Admin POST
        res = self.app.post(url, data=category, follow_redirects=True)
        err_msg = "Category should be updated"
        assert "Category updated" in res.data, err_msg
        assert category["name"] in res.data, err_msg
        updated_category = db.session.query(model.Category).get(obj.id)
        assert updated_category.name == obj.name, err_msg
        # With not valid form
        category["name"] = None
        res = self.app.post(url, data=category, follow_redirects=True)
        assert "Please correct the errors" in res.data, err_msg
开发者ID:nmashton,项目名称:pybossa,代码行数:52,代码来源:test_admin.py

示例15: test_18_admin_delete_tasks

# 需要导入模块: from base import Fixtures [as 别名]
# 或者: from base.Fixtures import create [as 别名]
 def test_18_admin_delete_tasks(self):
     """Test ADMIN can delete an app's tasks that belongs to another user"""
     # Admin
     Fixtures.create()
     tasks = db.session.query(model.Task).filter_by(app_id=1).all()
     assert len(tasks) > 0, "len(app.tasks) > 0"
     res = self.signin(email=u"[email protected]", password=u"tester" + "root")
     res = self.app.get("/app/test-app/tasks/delete", follow_redirects=True)
     err_msg = "Admin user should get 200 in GET"
     assert res.status_code == 200, err_msg
     res = self.app.post("/app/test-app/tasks/delete", follow_redirects=True)
     err_msg = "Admin should get 200 in POST"
     assert res.status_code == 200, err_msg
     tasks = db.session.query(model.Task).filter_by(app_id=1).all()
     assert len(tasks) == 0, "len(app.tasks) != 0"
开发者ID:svanderwaal,项目名称:pybossa,代码行数:17,代码来源:test_admin.py


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