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


Python tests.user_set函数代码示例

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


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

示例1: test_comaintain_package

    def test_comaintain_package(self, login_func):
        """ Test the comaintain_package function. """
        login_func.return_value=None

        create_package_acl(self.session)

        user = FakeFasUser()
        with user_set(pkgdb.APP, user):
            output = self.app.get(
                '/acl/guake/comaintain/', follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<li class="message">ACLs updated</li>' in output.data)

            output = self.app.get(
                '/acl/random/comaintain/', follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<li class="error">No package found by this name</li>'
                in output.data)

        user = FakeFasUser()
        user.groups = ['gitr2spec']
        with user_set(pkgdb.APP, user):
            output = self.app.get(
                '/acl/guake/comaintain/', follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<li class="errors">You must be a packager</li>'
                in output.data)
开发者ID:msmahmood,项目名称:packagedb2,代码行数:30,代码来源:test_flask_ui_acls.py

示例2: test_index_filled

    def test_index_filled(self):
        """ Test the index function. """
        self.setup_db()
        output = self.app.get('/')
        self.assertEqual(output.status_code, 200)
        self.assertTrue('<h2>Elections' in output.data)
        self.assertTrue('<h4><strong>Open elections</strong></h4>' in output.data)
        self.assertTrue('<strong>Upcoming elections</strong></h4>' in output.data)
        self.assertTrue('<a href="/login">Log In</a>' in output.data)

        user = FakeUser([], username='pingou')
        with user_set(fedora_elections.APP, user):
            output = self.app.get('/')
            self.assertEqual(output.status_code, 200)
            self.assertTrue('<h2>Elections' in output.data)
            self.assertTrue('<h4><strong>Open elections</strong></h4>' in output.data)
            self.assertTrue('<strong>Upcoming elections</strong></h4>' in output.data)
            self.assertTrue('<a class="btn btn-sm btn-primary m-l-2" href="/vote/' in output.data)
            self.assertTrue(
                '<a class="dropdown-item" href="/logout">log out</a>' in output.data)
            self.assertEqual(output.data.count('Vote now!'), 4)

        user = FakeUser([], username='toshio')
        with user_set(fedora_elections.APP, user):
            output = self.app.get('/')
            self.assertEqual(output.status_code, 200)
            self.assertTrue('<h2>Elections' in output.data)
            self.assertTrue('<h4><strong>Open elections</strong></h4>' in output.data)
            self.assertTrue('<strong>Upcoming elections</strong></h4>' in output.data)
            self.assertTrue(
                '<a class="dropdown-item" href="/logout">log out</a>' in output.data)
开发者ID:fedora-infra,项目名称:elections,代码行数:31,代码来源:test_flask.py

示例3: test_new_request_pull

    def test_new_request_pull(self, send_email):
        """ Test the new_request_pull endpoint when the git repo has no
        master branch.
        """
        send_email.return_value = True

        tests.create_projects(self.session)
        # Non-existant git repo
        output = self.app.get('/test/diff/master..feature')
        # (used to be 302 but seeing a diff is allowed even logged out)
        self.assertEqual(output.status_code, 404)

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/test/diff/master..feature')
            self.assertEqual(output.status_code, 404)

        self.set_up_git_repo()

        output = self.app.get('/test/diff/master..feature')
        # (used to be 302 but seeing a diff is allowed even logged out)
        self.assertEqual(output.status_code, 400)
        self.assertIn(
            '<p>Branch master could not be found in the target repo</p>',
            output.data)

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/test/diff/master..feature')
            self.assertEqual(output.status_code, 400)
            self.assertIn(
                '<p>Branch master could not be found in the target repo</p>',
                output.data)
开发者ID:trasher,项目名称:ProGit,代码行数:33,代码来源:test_pagure_flask_ui_no_master_branch.py

示例4: test_admin

    def test_admin(self, login_func):
        """ Test the admin function. """
        login_func.return_value = None

        user = tests.FakeFasUser()
        with tests.user_set(mirrormanager2.app.APP, user):
            output = self.app.get('/admin/')
            self.assertEqual(output.status_code, 200)
            data = output.get_data(as_text=True)
            self.assertTrue('<title>Home - Admin</title>' in data)
            self.assertFalse(
                '<a href="/admin/archview/">Arch</a>' in data)
            self.assertFalse(
                '<a href="/admin/categoryview/">Category</a>' in data)

        user = tests.FakeFasUserAdmin()
        with tests.user_set(mirrormanager2.app.APP, user):
            output = self.app.get('/admin/')
            self.assertEqual(output.status_code, 200)
            data = output.get_data(as_text=True)
            self.assertTrue('<title>Home - Admin</title>' in data)
            self.assertTrue(re.search(
                '<a href="/admin/arch(view)?/">Arch</a>', data))
            self.assertTrue(re.search(
                '<a href="/admin/category(view)?/">Category</a>', data))
开发者ID:fedora-infra,项目名称:mirrormanager2,代码行数:25,代码来源:test_ui_admin.py

示例5: test_new_request_pull

    def test_new_request_pull(self, send_email):
        """ Test the new_request_pull endpoint when the git repo has no
        master branch.
        """
        send_email.return_value = True

        tests.create_projects(self.session)
        # Non-existant git repo
        output = self.app.get('/test/diff/master..maxamilion/feature')
        self.assertEqual(output.status_code, 302)

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/test/diff/master..maxamilion/feature')
            self.assertEqual(output.status_code, 404)

        self.set_up_git_repo()

        output = self.app.get('/test/diff/master..maxamilion/feature')
        self.assertEqual(output.status_code, 302)

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/test/diff/master..maxamilion/feature')
            self.assertEqual(output.status_code, 200)
            self.assertEqual(
                output.data.count('<td class="commitid">'), 1)
            self.assertIn('<h3>.gitignore</h3>', output.data)
开发者ID:girish946,项目名称:pagure,代码行数:28,代码来源:test_progit_flask_ui_slash_branch_name.py

示例6: test_index_filled

    def test_index_filled(self):
        """ Test the index function. """
        self.setup_db()
        output = self.app.get('/')
        self.assertEqual(output.status_code, 200)
        self.assertTrue('<title>Fedora elections</title>' in output.data)
        self.assertTrue('<h3>Current elections</h3>' in output.data)
        self.assertTrue('<h3>Next 1 elections</h3>' in output.data)
        self.assertTrue('<h3>Last 2 elections</h3>' in output.data)
        self.assertTrue('<a href="/login">login</a>' in output.data)

        user = FakeUser([], username='pingou')
        with user_set(fedora_elections.APP, user):
            output = self.app.get('/')
            self.assertEqual(output.status_code, 200)
            self.assertTrue('<title>Fedora elections</title>' in output.data)
            self.assertTrue('<h3>Current elections</h3>' in output.data)
            self.assertTrue('<h3>Next 1 elections</h3>' in output.data)
            self.assertTrue('<h3>Last 2 elections</h3>' in output.data)
            self.assertTrue('<a href="/vote/' in output.data)
            self.assertTrue(
                '<span class="text">logged in as </span>' in output.data)
            self.assertEqual(output.data.count('Vote now!'), 4)

        user = FakeUser([], username='toshio')
        with user_set(fedora_elections.APP, user):
            output = self.app.get('/')
            self.assertEqual(output.status_code, 200)
            self.assertTrue('<title>Fedora elections</title>' in output.data)
            self.assertTrue('<h3>Current elections</h3>' in output.data)
            self.assertTrue('<h3>Next 1 elections</h3>' in output.data)
            self.assertTrue('<h3>Last 2 elections</h3>' in output.data)
            self.assertTrue(
                '<span class="text">logged in as </span>' in output.data)
            self.assertEqual(output.data.count('Vote now!'), 0)
开发者ID:NerdsvilleCEO,项目名称:elections,代码行数:35,代码来源:test_flask.py

示例7: test_new_request_pull

    def test_new_request_pull(self, send_email):
        """ Test the new_request_pull endpoint when the git repo has no
        master branch.
        """
        send_email.return_value = True

        tests.create_projects(self.session)
        # Non-existant git repo
        output = self.app.get('/test/diff/master..maxamilion/feature')
        # (used to be 302 but seeing a diff is allowed even logged out)
        self.assertEqual(output.status_code, 404)

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/test/diff/master..maxamilion/feature')
            self.assertEqual(output.status_code, 404)

        self.set_up_git_repo()

        output = self.app.get('/test/diff/master..maxamilion/feature')
        # (used to be 302 but seeing a diff is allowed even logged out)
        self.assertEqual(output.status_code, 200)
        self.assertEqual(
            output.data.count('<span class="commitdate" title='), 1)
        self.assertIn('<h5>.gitignore', output.data)

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/test/diff/master..maxamilion/feature')
            self.assertEqual(output.status_code, 200)
            self.assertEqual(
                output.data.count('<span class="commitdate" title='), 1)
            self.assertIn('<h5>.gitignore', output.data)
开发者ID:rahulbajaj0509,项目名称:pagure,代码行数:33,代码来源:test_progit_flask_ui_slash_branch_name.py

示例8: test_dropcommit_package

    def test_dropcommit_package(self, login_func, mock_func):
        """ Test the dropcommit_package function. """
        login_func.return_value = None

        create_package_acl(self.session)

        user = FakeFasUser()
        mock_func.return_value = ['pingou', 'ralph', 'kevin']

        with user_set(pkgdb2.APP, user):
            output = self.app.get(
                '/acl/guake/dropcommit/', follow_redirects=True)
            self.assertEqual(output.status_code, 405)

        with user_set(pkgdb2.APP, user):
            output = self.app.get('/package/guake/')
            csrf_token = output.data.split(
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]
            data = {'csrf_token': csrf_token}

            output = self.app.post(
                '/acl/guake/dropcommit/',
                data=data, follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<li class="message">ACLs updated</li>' in output.data)

            output = self.app.post(
                '/acl/random/dropcommit/',
                data=data, follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<li class="error">No package found by this name</li>'
                in output.data)
开发者ID:charulagrl,项目名称:pkgdb2,代码行数:34,代码来源:test_flask_ui_acls.py

示例9: test_vote_irc

    def test_vote_irc(self):
        """ Test the vote_irc function - the preview part. """
        output = self.app.get(
            '/vote/test_election', follow_redirects=True)
        self.assertEqual(output.status_code, 200)
        self.assertTrue(
            '<title>OpenID transaction in progress</title>' in output.data
            or 'discoveryfailure' in output.data)

        self.setup_db()

        user = FakeUser(['packager'], username='toshio')
        with user_set(fedora_elections.APP, user):
            output = self.app.get(
                '/vote/test_election7', follow_redirects=True)
            self.assertTrue(
                'class="message">You have already voted in the election!</'
                in output.data)

        user = FakeUser(['packager'], username='nerdsville')
        with user_set(fedora_elections.APP, user):
            output = self.app.get(
                '/vote/test_election7')
            self.assertTrue(
                '<h2>test election 7 shortdesc</h2>' in output.data)
            self.assertTrue(
                '<input type="hidden" name="action" value="preview" />'
                in output.data)

            csrf_token = output.data.split(
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]

            # Invalid vote: No candidate
            data = {
                'action': 'preview',
            }

            output = self.app.post('/vote/test_election7', data=data)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<h2>test election 7 shortdesc</h2>' in output.data)

            # Valid input
            data = {
                'Kevin': -1,
                'Toshio': '0',
                'action': 'preview',
                'csrf_token': csrf_token,
            }

            output = self.app.post('/vote/test_election7', data=data)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<h2>test election 7 shortdesc</h2>' in output.data)
            self.assertTrue(
                '<input type="hidden" name="action" value="submit" />'
                in output.data)
            self.assertTrue(
                '<li class="message">Please confirm your vote!</li>'
                in output.data)
开发者ID:NerdsvilleCEO,项目名称:elections,代码行数:60,代码来源:test_flask_irc.py

示例10: test_view_plugin_page

    def test_view_plugin_page(self):
        """ Test the view_plugin_page endpoint. """

        output = self.app.get('/foo/settings/Mail')
        self.assertEqual(output.status_code, 302)

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/foo/settings/Mail')
            self.assertEqual(output.status_code, 404)

            tests.create_projects(self.session)
            tests.create_projects_git(tests.HERE)

            output = self.app.get('/test/settings/Mail')
            self.assertEqual(output.status_code, 403)

        user.username = 'pingou'
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/test/settings/Mail')
            self.assertEqual(output.status_code, 200)
            self.assertIn(
                '<form action="/test/settings/Mail" method="post">',
                output.data)
            self.assertIn(
                '<td><label for="mail_to">Mail to</label></td>',
                output.data)

            csrf_token = output.data.split(
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]

            data = {
                'active': True,
                'mail_to': '[email protected]',
                'csrf_token': csrf_token,
            }

            output = self.app.post(
                '/test/settings/Mail', data=data, follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertIn(
                '<section class="settings">\n  <h3>Settings for test</h3>',
                output.data)
            self.assertIn(
                '</button>\n                      Hook Mail activated', output.data)

            data = {
                'mail_to': '',
                'csrf_token': csrf_token,
            }

            output = self.app.post(
                '/test/settings/Mail', data=data, follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertIn(
                '<section class="settings">\n  <h3>Settings for test</h3>',
                output.data)
            self.assertIn(
                '</button>\n                      Hook Mail inactived', output.data)
开发者ID:denys-duchier,项目名称:pagure,代码行数:59,代码来源:test_pagure_flask_ui_plugins.py

示例11: test_repo_stargazers

    def test_repo_stargazers(self):
        """ Test the repo_stargazers endpoint of pagure.ui.repo """

        # make pingou star the project
        # first create pingou
        user = tests.FakeUser()
        user.username = "pingou"
        with tests.user_set(self.app.application, user):
            csrf_token = self.get_csrf()
            data = {"csrf_token": csrf_token}

            output = self.app.post(
                "/test/star/1", data=data, follow_redirects=True
            )
            self.assertEqual(output.status_code, 200)
            self.assertIn(
                "You starred this project", output.get_data(as_text=True)
            )
            self._check_star_count(data=data, stars=1)

        # now, test if pingou's name comes in repo stargazers
        output = self.app.get("/test/stargazers/")
        self.assertIn(
            "<title>Stargazers of test  - Pagure</title>",
            output.get_data(as_text=True),
        )
        self.assertIn(
            '<a class="font-weight-bold" href="/user/pingou">pingou</a>',
            output.get_data(as_text=True),
        )

        # make pingou unstar the project
        user = tests.FakeUser()
        user.username = "pingou"
        with tests.user_set(self.app.application, user):
            csrf_token = self.get_csrf()
            data = {"csrf_token": csrf_token}

            output = self.app.post(
                "/test/star/0", data=data, follow_redirects=True
            )
            self.assertEqual(output.status_code, 200)
            self.assertIn(
                "You unstarred this project", output.get_data(as_text=True)
            )
            self._check_star_count(data=data, stars=0)

        # now, test if pingou's name comes in repo stargazers
        # it shouldn't because, he just unstarred
        output = self.app.get("/test/stargazers/")
        self.assertIn(
            "<title>Stargazers of test  - Pagure</title>",
            output.get_data(as_text=True),
        )
        self.assertNotIn(
            '<a class="font-weight-bold" href="/user/pingou">pingou</a>',
            output.get_data(as_text=True),
        )
开发者ID:pypingou,项目名称:pagure,代码行数:58,代码来源:test_pagure_flask_ui_star_project.py

示例12: test_new_project

    def test_new_project(self):
        """ Test the new_project endpoint. """
        # Before
        projects = pagure.lib.search_projects(self.session)
        self.assertEqual(len(projects), 0)
        self.assertFalse(os.path.exists(os.path.join(tests.HERE, "project#1.git")))
        self.assertFalse(os.path.exists(os.path.join(tests.HERE, "tickets", "project#1.git")))
        self.assertFalse(os.path.exists(os.path.join(tests.HERE, "docs", "project#1.git")))
        self.assertFalse(os.path.exists(os.path.join(tests.HERE, "requests", "project#1.git")))

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get("/new/")
            self.assertEqual(output.status_code, 200)
            self.assertIn("<strong>Create new Project</strong>", output.data)

            csrf_token = output.data.split('name="csrf_token" type="hidden" value="')[1].split('">')[0]

            data = {"description": "Project #1"}

            output = self.app.post("/new/", data=data)
            self.assertEqual(output.status_code, 200)
            self.assertIn("<strong>Create new Project</strong>", output.data)
            self.assertIn(
                "<small>\n                      This field is required." "&nbsp;\n                    </small>",
                output.data,
            )

            data["name"] = "project-1"
            output = self.app.post("/new/", data=data)
            self.assertEqual(output.status_code, 200)
            self.assertIn("<strong>Create new Project</strong>", output.data)
            self.assertNotIn(
                "<small>\n                      This field is required." "&nbsp;\n                    </small>",
                output.data,
            )

            data["csrf_token"] = csrf_token
            output = self.app.post("/new/", data=data)
            self.assertEqual(output.status_code, 200)
            self.assertIn("<strong>Create new Project</strong>", output.data)
            self.assertIn("</button>\n                      No user &#34;username&#34; found", output.data)

        user.username = "foo"
        with tests.user_set(pagure.APP, user):
            data["csrf_token"] = csrf_token
            output = self.app.post("/new/", data=data, follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue("<p>Project #1</p>" in output.data)
            self.assertIn("</button>\n                      Project &#34;project-1&#34; created", output.data)

        # After
        projects = pagure.lib.search_projects(self.session)
        self.assertEqual(len(projects), 1)
        self.assertTrue(os.path.exists(os.path.join(tests.HERE, "project-1.git")))
        self.assertTrue(os.path.exists(os.path.join(tests.HERE, "tickets", "project-1.git")))
        self.assertTrue(os.path.exists(os.path.join(tests.HERE, "docs", "project-1.git")))
        self.assertTrue(os.path.exists(os.path.join(tests.HERE, "requests", "project-1.git")))
开发者ID:rahulbajaj0509,项目名称:pagure,代码行数:58,代码来源:test_progit_flask_ui_app.py

示例13: test_user_settings

    def test_user_settings(self, ast):
        """ Test the user_settings endpoint. """
        ast.return_value = False
        self.test_new_project()

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/settings/')
            self.assertEqual(output.status_code, 404)
            self.assertTrue('<h2>Page not found (404)</h2>' in output.data)

        user.username = 'foo'
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/settings/')
            self.assertEqual(output.status_code, 200)
            self.assertIn(
                '<div class="card-header">\n          Basic Information\n'
                '      </div>', output.data)
            self.assertIn(
                '<textarea class="form-control" id="ssh_key" name="ssh_key">'
                '</textarea>', output.data)

            csrf_token = output.data.split(
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]

            data = {
                'ssh_key': 'this is my ssh key',
            }

            output = self.app.post('/settings/', data=data)
            self.assertEqual(output.status_code, 200)
            self.assertIn(
                '<div class="card-header">\n          Basic Information\n'
                '      </div>', output.data)
            self.assertIn(
                '<textarea class="form-control" id="ssh_key" name="ssh_key">'
                'this is my ssh key</textarea>', output.data)

            data['csrf_token'] =  csrf_token

            output = self.app.post(
                '/settings/', data=data, follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '</button>\n                      Public ssh key updated'
                in output.data)
            self.assertIn(
                '<div class="card-header">\n          Basic Information\n'
                '      </div>', output.data)
            self.assertIn(
                '<textarea class="form-control" id="ssh_key" name="ssh_key">'
                'this is my ssh key</textarea>', output.data)

            ast.return_value = True
            output = self.app.get('/settings/')
            self.assertEqual(output.status_code, 302)
开发者ID:jepio,项目名称:pagure,代码行数:56,代码来源:test_pagure_flask_ui_app.py

示例14: test_new_project_when_turned_off

    def test_new_project_when_turned_off(self):
        """ Test the new_project endpoint when new project creation is
        not allowed in the pagure instance. """

        #turn the project creation off
        pagure.APP.config['ENABLE_NEW_PROJECTS'] = False

        # Before
        projects = pagure.lib.search_projects(self.session)
        self.assertEqual(len(projects), 0)
        self.assertFalse(os.path.exists(
            os.path.join(tests.HERE, 'project-1.git')))
        self.assertFalse(os.path.exists(
            os.path.join(tests.HERE, 'tickets', 'project-1.git')))
        self.assertFalse(os.path.exists(
            os.path.join(tests.HERE, 'docs', 'project-1.git')))
        self.assertFalse(os.path.exists(
            os.path.join(tests.HERE, 'requests', 'project-1.git')))

        user = tests.FakeUser()
        with tests.user_set(pagure.APP, user):
            output = self.app.get('/new/')
            self.assertEqual(output.status_code, 404)

            #just get the csrf token
            pagure.APP.config['ENABLE_NEW_PROJECTS'] = True
            output = self.app.get('/new/')
            pagure.APP.config['ENABLE_NEW_PROJECTS'] = False

            csrf_token = output.data.split(
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]

            data = {
                'description': 'Project #1',
                'name': 'project-1',
            }

        user.username = 'foo'
        with tests.user_set(pagure.APP, user):
            data['csrf_token'] =  csrf_token
            output = self.app.post('/new/', data=data, follow_redirects=True)
            self.assertEqual(output.status_code, 404)

        #After
        projects = pagure.lib.search_projects(self.session)
        self.assertEqual(len(projects), 0)
        self.assertFalse(os.path.exists(
            os.path.join(tests.HERE, 'project-1.git')))
        self.assertFalse(os.path.exists(
            os.path.join(tests.HERE, 'tickets', 'project-1.git')))
        self.assertFalse(os.path.exists(
            os.path.join(tests.HERE, 'docs', 'project-1.git')))
        self.assertFalse(os.path.exists(
            os.path.join(tests.HERE, 'requests', 'project-1.git')))

        pagure.APP.config['ENABLE_NEW_PROJECTS'] = True
开发者ID:trasher,项目名称:ProGit,代码行数:56,代码来源:test_pagure_flask_ui_app.py

示例15: test_admin_new_release

    def test_admin_new_release(self):
        """ Test the admin_new_release function. """
        user = None
        with user_set(app.APP, user):
            output = self.app.get('/admin/new', follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<title>OpenID transaction in progress</title>'
                in output.data)

        user = FakeFasUser()
        user.groups = []
        user.cla_done = False
        with user_set(app.APP, user):
            output = self.app.get('/admin/new', follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<li class="error">You are not an admin</li>' in output.data)

        user = FakeFasUser()
        user.groups = []
        with user_set(app.APP, user):
            output = self.app.get('/admin/new', follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<li class="error">You are not an admin</li>' in output.data)

        user = FakeFasUser()
        user.groups.append('sysadmin-main')
        with user_set(app.APP, user):
            output = self.app.get('/admin/new')
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<title> New release' in output.data)
            self.assertTrue(
                "<label for=\"releasenum\">Release number <span "
                "class='error'>*</span></label>" in output.data)

            csrf_token = output.data.split(
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]

            data = {
                'csrf_token': csrf_token,
                'releasenum': 20,
                'support': 'RELEASE',
            }

            output = self.app.post(
                '/admin/new', data=data, follow_redirects=True)
            self.assertEqual(output.status_code, 200)
            self.assertTrue(
                '<li class="message">Release &#34;20&#34; added</li>'
                in output.data)
            self.assertTrue("<a href='/release/20'>" in output.data)
            self.assertTrue("<a href='/admin/20/edit'" in output.data)
开发者ID:Altiscale,项目名称:kerneltest-harness,代码行数:55,代码来源:test_app.py


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