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


Python tests.create_package_acl函数代码示例

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


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

示例1: test_get_acl_package

    def test_get_acl_package(self):
        """ Test the get_acl_package function. """
        create_package_acl(self.session)

        packages = model.Package.all(self.session)
        self.assertEqual(3, len(packages))
        self.assertEqual('guake', packages[0].name)

        pkg_acl = pkgdblib.get_acl_package(self.session, 'guake')
        self.assertEqual(len(pkg_acl), 2)
        self.assertEqual(pkg_acl[0].collection.branchname, 'F-18')
        self.assertEqual(pkg_acl[0].package.name, 'guake')
        self.assertEqual(pkg_acl[0].acls[0].fas_name, 'pingou')

        pkg_acl = pkgdblib.get_acl_package(self.session, 'guake', 'devel')
        self.assertEqual(pkg_acl.collection.branchname, 'devel')
        self.assertEqual(pkg_acl.package.name, 'guake')
        self.assertEqual(pkg_acl.acls[0].fas_name, 'pingou')

        # Collection does not exist
        self.assertRaises(pkgdblib.PkgdbException,
                          pkgdblib.get_acl_package,
                          self.session,
                          'guake',
                          'unknown')
开发者ID:ralphbean,项目名称:packagedb2,代码行数:25,代码来源:test_pkgdblib.py

示例2: 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

示例3: test_packager_list

    def test_packager_list(self):
        """ Test the api_packager_list function.  """
        output = self.app.get('/api/packager/list/pin*')
        self.assertEqual(output.status_code, 301)

        output = self.app.get('/api/packager/list/')
        self.assertEqual(output.status_code, 500)
        self.assertEqual(output.data,
                         '{\n  "output": "notok",\n  '
                         '"error": "Invalid request"\n}')

        output = self.app.get('/api/packager/list/pin*/')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data,
                         '{\n  "output": "ok",\n  "packagers": []\n}')

        create_package_acl(self.session)

        output = self.app.get('/api/packager/list/pin*/')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['output', 'packagers'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(len(output['packagers']), 1)
        self.assertEqual(output['packagers'][0], 'pingou')
开发者ID:ralphbean,项目名称:packagedb2,代码行数:26,代码来源:test_flask_api_packagers.py

示例4: test_acl_get

    def test_acl_get(self):
        """ Test the api_acl_get function.  """
        output = self.app.get('/api/package/acl/get/guake')
        self.assertEqual(output.status_code, 301)

        output = self.app.get('/api/package/acl/get/guake/')
        self.assertEqual(output.status_code, 500)
        self.assertEqual(output.data,
                         '{\n  "output": "notok",\n  '
                         '"error": "No package found with name '
                         '\\"guake\\""\n}')

        output = self.app.get('/api/package/acl/get/')
        self.assertEqual(output.status_code, 500)
        self.assertEqual(output.data,
                         '{\n  "output": "notok",\n  '
                         '"error": "No package provided"\n}')

        create_package_acl(self.session)

        output = self.app.get('/api/package/acl/get/guake/')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(output.keys(),
                         ['acls'])
        self.assertEqual(len(output['acls']), 2)
        self.assertEqual(output['acls'][0]['collection']['branchname'],
                         'F-18')
        self.assertEqual(output['acls'][0]['point_of_contact'],
                         'pingou')
        self.assertEqual(output['acls'][1]['collection']['branchname'],
                         'devel')
        self.assertEqual(output['acls'][1]['point_of_contact'],
                         'pingou')
开发者ID:ralphbean,项目名称:packagedb2,代码行数:34,代码来源:test_flask_api_acls.py

示例5: 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

示例6: test_packager_list

    def test_packager_list(self):
        """ Test the api_packager_list function.  """

        output = self.app.get('/api/packagers/')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "output": "ok",
                "packagers": [],
            }
        )

        output = self.app.get('/api/packagers/pin*/')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "output": "ok",
                "packagers": [],
            }
        )

        create_package_acl(self.session)

        output = self.app.get('/api/packagers/pin*/')
        self.assertEqual(output.status_code, 200)
        output = json.loads(output.data)
        self.assertEqual(sorted(output.keys()),
                         ['output', 'packagers'])
        self.assertEqual(output['output'], 'ok')
        self.assertEqual(len(output['packagers']), 1)
        self.assertEqual(output['packagers'][0], 'pingou')
开发者ID:cydrobolt,项目名称:pkgdb2,代码行数:35,代码来源:test_flask_api_packagers.py

示例7: test_get_critpath_packages

    def test_get_critpath_packages(self):
        """ Test the get_critpath_packages method of PackageListing. """
        create_package_acl(self.session)

        pkg_list = model.PackageListing.get_critpath_packages(self.session)
        self.assertEqual(pkg_list, [])

        pkg_list = model.PackageListing.get_critpath_packages(
            self.session, branch='devel')
        self.assertEqual(pkg_list, [])

        create_package_critpath(self.session)

        pkg_list = model.PackageListing.get_critpath_packages(self.session)
        self.assertEqual(len(pkg_list), 2)
        self.assertEqual(
            pkg_list[0].point_of_contact, "kernel-maint")
        self.assertEqual(
            pkg_list[0].collection.branchname, "F-18")
        self.assertEqual(
            pkg_list[1].point_of_contact, "group::kernel-maint")
        self.assertEqual(
            pkg_list[1].collection.branchname, "devel")

        pkg_list = model.PackageListing.get_critpath_packages(
            self.session, branch='devel')
        self.assertEqual(len(pkg_list), 1)
        self.assertEqual(
            pkg_list[0].point_of_contact, "group::kernel-maint")
        self.assertEqual(
            pkg_list[0].collection.branchname, "devel")
开发者ID:msmahmood,项目名称:packagedb2,代码行数:31,代码来源:test_package_listing.py

示例8: test_stats

    def test_stats(self):
        """ Test the stats function. """
        output = self.app.get('/stats')
        self.assertEqual(output.status_code, 301)
        output = self.app.get('/stats/')
        self.assertEqual(output.status_code, 200)
        expected = """<h1>Fedora Package Database</h1>

<p>
    PkgDB stores currently information about 0
    active Fedora releases.
</p>"""
        self.assertTrue(expected in output.data)

        create_package_acl(self.session)

        output = self.app.get('/stats')
        self.assertEqual(output.status_code, 301)
        output = self.app.get('/stats/')
        self.assertEqual(output.status_code, 200)
        expected = """<h1>Fedora Package Database</h1>

<p>
    PkgDB stores currently information about 3
    active Fedora releases.
</p>"""
        self.assertTrue(expected in output.data)
开发者ID:Ghost-script,项目名称:pkgdb2,代码行数:27,代码来源:test_flask.py

示例9: test_to_json

    def test_to_json(self):
        """ Test the to_json function of PersonPackageListing. """
        packager = model.PackageListingAcl.get_acl_packager(
            self.session, 'pingou')
        self.assertEqual(0, len(packager))

        create_package_acl(self.session)

        packager = model.PackageListingAcl.get_acl_packager(
            self.session, 'pingou')
        self.assertEqual(4, len(packager))
        output = packager[0].to_json()
        self.assertEqual(output,
        {
            'status': u'Approved',
            'acl': 'commit',
            'fas_name': u'pingou',
            'packagelist': {
                'point_of_contact': u'pingou',
                'collection': {
                    'pendingurltemplate': None,
                    'publishurltemplate': None,
                    'branchname': u'F-18',
                    'version': u'18',
                    'name': u'Fedora'
                }, 
                'package': {
                    'upstreamurl': u'http://guake.org',
                    'name': u'guake',
                    'reviewurl': u'https://bugzilla.redhat.com/450189',
                    'summary': u'Top down terminal for GNOME'
                }
            }
        }
        )
开发者ID:ralphbean,项目名称:packagedb2,代码行数:35,代码来源:test_package_listing_acl.py

示例10: test_get_package_of_user

    def test_get_package_of_user(self):
        """ Test the get_package_of_user function of Package. """
        create_package_acl(self.session)

        packages = model.Package.get_package_of_user(
            self.session, user='pingou', poc=True
        )
        self.assertEqual(len(packages), 2)
        self.assertEqual(packages[0][0].name, 'guake')

        expected = set(['master', 'f18'])
        branches = set([packages[0][1].branchname,
                        packages[1][1].branchname])
        self.assertEqual(branches.symmetric_difference(expected), set())

        packages = model.Package.get_package_of_user(
            self.session, user='pingou', poc=False
        )
        self.assertEqual(packages, [])

        packages = model.Package.get_package_of_user(
            self.session,
            user='pingou',
            pkg_status='Awaiting Review',
        )
        self.assertEqual(len(packages), 0)
开发者ID:mizdebsk,项目名称:pkgdb2,代码行数:26,代码来源:test_package.py

示例11: test_api_package_info

    def test_api_package_info(self):
        """ Test the api_package_info function.  """

        output = self.app.get('/api/package/guake/')
        self.assertEqual(output.status_code, 404)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "error": "Package: guake not found",
                "output": "notok"
            }
        )

        create_package_acl(self.session)

        output = self.app.get('/api/package/guake/')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(data.keys(), ['output', 'packages'])
        self.assertEqual(len(data['packages']), 2)
        self.assertEqual(data['output'], 'ok')
        self.assertEqual(data['packages'][0]['collection']['branchname'],
                         'F-18')
        self.assertEqual(data['packages'][0]['point_of_contact'],
                         'pingou')
        self.assertEqual(data['packages'][0]['package']['name'],
                         'guake')
        self.assertEqual(data['packages'][1]['collection']['branchname'],
                         'devel')
        self.assertEqual(data['packages'][1]['point_of_contact'],
                         'pingou')
        self.assertEqual(data['packages'][1]['package']['name'],
                         'guake')

        output = self.app.get('/api/package/?pkg_name=guake&pkg_clt=devel')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        self.assertEqual(data.keys(), ['output', 'packages'])
        self.assertEqual(len(data['packages']), 1)
        self.assertEqual(data['output'], 'ok')
        self.assertEqual(data['packages'][0]['collection']['branchname'],
                         'devel')
        self.assertEqual(data['packages'][0]['point_of_contact'],
                         'pingou')
        self.assertEqual(data['packages'][0]['package']['name'],
                         'guake')

        output = self.app.get('/api/package/?pkg_name=guake&pkg_clt=F-19')
        self.assertEqual(output.status_code, 500)
        data = json.loads(output.data)
        self.assertEqual(
            data,
            {
                "error": "Collection F-19 is not associated with package "
                "guake",
                "output": "notok"
            }
        )
开发者ID:pombredanne,项目名称:packagedb2,代码行数:59,代码来源:test_flask_api_packages.py

示例12: test_api_pendingacls_filled

    def test_api_pendingacls_filled(self):
        """ Test the api_pendingacls function with a filled database. """
        # Fill the DB
        create_package_acl(self.session)
        create_package_critpath(self.session)

        output = self.app.get('/api/pendingacls/')
        self.assertEqual(output.status_code, 200)

        expected = """# Number of requests pending: 2
guake:master has ralph waiting for approveacls
guake:master has toshio waiting for commit"""
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/pendingacls/?format=random')
        self.assertEqual(output.status_code, 200)
        self.assertEqual(output.data, expected)

        output = self.app.get('/api/pendingacls/?format=json')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        expected = {
            'pending_acls': [
                {
                    'acl': 'approveacls',
                    'collection': 'master',
                    'namespace': 'rpms',
                    'package': 'guake',
                    'status': 'Awaiting Review',
                    'user': 'ralph'
                },
                {
                    'acl': 'commit',
                    'collection': 'master',
                    'namespace': 'rpms',
                    'package': 'guake',
                    'status': 'Awaiting Review',
                    'user': 'toshio'
                }
            ],
            'total_requests_pending': 2
        }

        self.assertEqual(data, expected)

        output = self.app.get('/api/pendingacls/?format=json&username=pingou')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)

        self.assertEqual(data, expected)

        output = self.app.get('/api/pendingacls/?format=json&username=toshio')
        self.assertEqual(output.status_code, 200)
        data = json.loads(output.data)
        expected = {'pending_acls': [], 'total_requests_pending': 0}

        self.assertEqual(data, expected)
开发者ID:cverna,项目名称:pkgdb2,代码行数:58,代码来源:test_flask_api_extras.py

示例13: test_search

    def test_search(self):
        """ Test the search function. """
        output = self.app.get('/search')
        self.assertEqual(output.status_code, 301)

        output = self.app.get('/search/', follow_redirects=True)
        self.assertEqual(output.status_code, 200)
        self.assertTrue('<h1>Search packages</h1>' in output.data)

        create_package_acl(self.session)

        output = self.app.get('/search/?term=g*', follow_redirects=True)
        self.assertEqual(output.status_code, 200)
        self.assertTrue('<h1>Search packages</h1>' in output.data)
        self.assertTrue('<a href="/package/geany/">' in output.data)
        self.assertTrue('<a href="/package/guake/">' in output.data)

        output = self.app.get('/search/?term=p&type=packager',
                              follow_redirects=True)
        self.assertEqual(output.status_code, 200)
        self.assertTrue(
            '<li class="message">Only one packager matching, redirecting '
            'you to his/her page</li>' in output.data)
        self.assertTrue('pingou</h1> (<a class="fas"' in output.data)

        output = self.app.get('/search/?term=g*', follow_redirects=True)
        self.assertEqual(output.status_code, 200)
        self.assertTrue('<h1>Search packages</h1>' in output.data)
        self.assertTrue('<a href="/package/geany/">' in output.data)
        self.assertTrue('<a href="/package/guake/">' in output.data)

        output = self.app.get('/search/?term=gu*', follow_redirects=True)
        self.assertEqual(output.status_code, 200)
        self.assertTrue(
            '<li class="message">Only one package matching, redirecting you'
            ' to it</li>' in output.data)
        self.assertTrue(
            '<p property="doap:shortdesc">Top down terminal for GNOME</p>'
            in output.data)

        output = self.app.get('/search/?term=g*&type=orphaned',
                              follow_redirects=True)
        self.assertEqual(output.status_code, 200)
        self.assertTrue('<h1>Search packages</h1>' in output.data)
        self.assertTrue('<p>0 packages found</p>' in output.data)
        expected = '<p>See the list of <a href="/packages/">active</a>\n' \
                   'or <a href="/retired/">retired</a> packages</p>'
        self.assertTrue(expected in output.data)

        output = self.app.get('/search/?term=g*&type=retired',
                              follow_redirects=True)
        self.assertEqual(output.status_code, 200)
        self.assertTrue('<h1>Search packages</h1>' in output.data)
        self.assertTrue('<p>0 packages found</p>' in output.data)
        expected = '<p>See the list of <a href="/packages/">active</a>\n' \
                   'or <a href="/orphaned/">orphaned</a> packages</p>'
        self.assertTrue(expected in output.data)
开发者ID:Ghost-script,项目名称:pkgdb2,代码行数:57,代码来源:test_flask.py

示例14: test_has_acls

    def test_has_acls(self):
        """ Test the has_acls function. """
        self.assertFalse(pkgdblib.has_acls(self.session, 'pingou',
            'guake', 'devel', 'approveacl'))

        create_package_acl(self.session)

        self.assertTrue(pkgdblib.has_acls(self.session, 'pingou',
            'guake', 'devel', 'commit'))
开发者ID:ralphbean,项目名称:packagedb2,代码行数:9,代码来源:test_pkgdblib.py

示例15: test_get_package_maintained

    def test_get_package_maintained(self):
        """ Test the get_package_maintained function. """
        create_package_acl(self.session)

        pkg = pkgdblib.get_package_maintained(self.session, 'pingou')
        self.assertEqual(len(pkg), 1)
        self.assertEqual(pkg[0].name, 'guake')

        pkg = pkgdblib.get_package_maintained(self.session, 'ralph')
        self.assertEqual(pkg, [])
开发者ID:ralphbean,项目名称:packagedb2,代码行数:10,代码来源:test_pkgdblib.py


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