本文整理汇总了Python中tests.FakeFasUser.groups方法的典型用法代码示例。如果您正苦于以下问题:Python FakeFasUser.groups方法的具体用法?Python FakeFasUser.groups怎么用?Python FakeFasUser.groups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.FakeFasUser
的用法示例。
在下文中一共展示了FakeFasUser.groups方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_admin_new_release
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
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 "20" added</li>'
in output.data)
self.assertTrue("<a href='/release/20'>" in output.data)
self.assertTrue("<a href='/admin/20/edit'" in output.data)
示例2: test_is_pkgdb_admin
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_is_pkgdb_admin(self):
""" Test the is_pkgdb_admin function of pkgdb2. """
user = FakeFasUser()
out = pkgdb2.is_pkgdb_admin(user)
self.assertEqual(out, False)
user.groups = []
out = pkgdb2.is_pkgdb_admin(user)
self.assertEqual(out, False)
user = FakeFasUser()
out = pkgdb2.is_pkgdb_admin(None)
self.assertEqual(out, False)
user = FakeFasUserAdmin()
out = pkgdb2.is_pkgdb_admin(user)
self.assertEqual(out, True)
pkgdb2.APP.config['ADMIN_GROUP'] = 'sysadmin-main'
out = pkgdb2.is_pkgdb_admin(user)
self.assertEqual(out, False)
# Reset the ADMIN_GROUP for the other tests
pkgdb2.APP.config['ADMIN_GROUP'] = ('sysadmin-main', 'sysadmin-cvs')
示例3: test_comaintain_package
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
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)
示例4: test_api_package_retire3
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_api_package_retire3(self, login_func, mock_func):
""" Test a third time the api_package_retire function. """
login_func.return_value = None
create_package_acl(self.session)
mock_func.log.return_value = ''
# Redirect as you are not a packager
user = FakeFasUser()
user.groups = []
# Add the EPEL 7 collection
collection = model.Collection(
name='Fedora EPEL',
version='7',
status='Active',
owner='kevin',
branchname='epel7',
dist_tag='.el7',
)
self.session.add(collection)
self.session.commit()
# Add guake to epel7
guake_pkg = model.Package.by_name(self.session, 'guake')
el7_collec = model.Collection.by_name(self.session, 'epel7')
pkgltg = model.PackageListing(
point_of_contact='orphan',
status='Orphaned',
package_id=guake_pkg.id,
collection_id=el7_collec.id,
)
self.session.add(pkgltg)
self.session.commit()
# Retire an orphaned package on an EPEL branch
user = FakeFasUser()
data = {
'pkgnames': 'guake',
'branches': ['epel7'],
}
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/retire/', data=data)
self.assertEqual(output.status_code, 200)
data = json.loads(output.data)
self.assertEqual(
data,
{
"messages": [""],
"output": "ok"
}
)
示例5: test_is_admin
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_is_admin(self):
""" Test the is_admin method. """
self.assertFalse(app.is_admin(None))
user = FakeFasUser()
user.cla_done = False
self.assertFalse(app.is_admin(user))
user = FakeFasUser()
user.groups = []
self.assertFalse(app.is_admin(user))
user = FakeFasUser()
user.groups.append('sysadmin-main')
self.assertTrue(app.is_admin(user))
示例6: test_request_acl
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_request_acl(self, login_func, mock_func):
""" Test the request_acl 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/request/')
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Request ACLs on package: guake</h1>' in output.data)
self.assertTrue(
'<input id="csrf_token" name="csrf_token"' in output.data)
self.assertTrue(
'<option value="approveacls">approveacls' in output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'branches': 'master',
'acl': 'watchbugzilla',
'csrf_token': csrf_token,
}
output = self.app.post('/acl/guake/request/', data=data,
follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue('<li class="message">ACLs updated</li>' in
output.data)
user.username = 'Toshio'
with user_set(pkgdb2.APP, user):
output = self.app.get('/acl/guake/request/')
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Request ACLs on package: guake</h1>' in output.data)
self.assertTrue(
'<input id="csrf_token" name="csrf_token"' in output.data)
self.assertTrue(
'<option value="approveacls">approveacls' in output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'branches': 'master',
'acl': 'watchbugzilla',
'csrf_token': csrf_token,
}
output = self.app.post('/acl/guake/request/', data=data,
follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue('<li class="message">ACLs updated</li>' in
output.data)
data = {
'branches': 'master',
'acl': 'commit',
'csrf_token': csrf_token,
}
output = self.app.post('/acl/guake/request/', data=data,
follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'class="error">User "Toshio" is not in the packager'
' group</' in output.data)
user = FakeFasUser()
user.groups = ['gitr2spec']
with user_set(pkgdb2.APP, user):
output = self.app.get('/acl/guake/request/')
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Request ACLs on package: guake</h1>' in output.data)
self.assertTrue(
'<input id="csrf_token" name="csrf_token"' in output.data)
self.assertTrue(
'<option value="approveacls">approveacls' in output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'branches': 'master',
'acl': 'commit',
'csrf_token': csrf_token,
}
output = self.app.post('/acl/guake/request/', data=data,
follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="message">ACLs updated</li>' in output.data)
self.assertTrue(
#.........这里部分代码省略.........
示例7: test_comaintain_package
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_comaintain_package(self, login_func, mock_func):
""" Test the comaintain_package function. """
login_func.return_value = None
create_package_acl(self.session)
user = FakeFasUser()
with user_set(pkgdb2.APP, user):
output = self.app.get(
'/acl/guake/comaintain/', 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/comaintain/',
data=data, follow_redirects=True)
self.assertTrue(
'<li class="error">You are already a co-maintainer on '
'f18</li>' in output.data)
self.assertFalse(
'<li class="message">ACLs updated</li>' in output.data)
output = self.app.post(
'/acl/random/comaintain/',
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)
user = FakeFasUser()
mock_func.return_value = ['pingou', 'ralph', 'kevin']
user.username = 'kevin'
with user_set(pkgdb2.APP, user):
output = self.app.post(
'/acl/guake/comaintain/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="message">ACLs updated</li>' in output.data)
# Nothing to update the second time
output = self.app.post(
'/acl/guake/comaintain/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="message">Nothing to update</li>' in output.data)
output = self.app.post(
'/acl/random/comaintain/',
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)
user = FakeFasUser()
user.groups = ['gitr2spec']
with user_set(pkgdb2.APP, user):
output = self.app.post(
'/acl/guake/comaintain/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="errors">You must be a packager</li>'
in output.data)
示例8: test_giveup_acl
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_giveup_acl(self, login_func, mock_func):
""" Test the giveup_acl function. """
login_func.return_value = None
create_package_acl(self.session)
user = FakeFasUser()
mock_func.return_value = ['pingou', 'ralph', 'kevin', 'dodji']
with user_set(pkgdb2.APP, user):
output = self.app.get(
'/acl/guake/giveup/approveacls/', follow_redirects=True)
self.assertEqual(output.status_code, 405)
user.username = 'dodji'
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/offlineimap/giveup/approveacls/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="error">No active branches found for you for '
'the ACL: approveacls</li>' in output.data)
user = FakeFasUser()
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/giveup/approveacls/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="message">Your ACL approveacls is obsoleted on '
'branch f18 of package guake</li>' in output.data)
self.assertTrue(
'<li class="message">Your ACL approveacls is obsoleted on '
'branch master of package guake</li>' in output.data)
self.assertEqual(
output.data.count('<a class="pending"'), 1)
output = self.app.post(
'/acl/guake/giveup/foobar/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="errors">Invalid ACL provided foobar.</li>'
in output.data)
output = self.app.post(
'/acl/barfoo/giveup/commit/',
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)
user.username = 'toshio'
user.groups = []
with user_set(pkgdb2.APP, user):
output = self.app.post(
'/acl/guake/giveup/commit/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="error">User "toshio" is not in the '
'packager group</li>' in output.data)
示例9: test_request_acl_all_branch
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_request_acl_all_branch(self, login_func, mock_func):
""" Test the request_acl_all_branch 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/request/approveacls/', 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/request/approveacls/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'class="message">ACL approveacls requested on branch f18</li>'
in output.data)
self.assertTrue(
'class="message">ACL approveacls requested on branch master</l'
in output.data)
self.assertEqual(
output.data.count('<a class="pending"'), 2)
output = self.app.post(
'/acl/guake/request/foobar/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="errors">Invalid ACL provided foobar.</li>'
in output.data)
output = self.app.post(
'/acl/barfoo/request/commit/',
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)
user.username = 'toshio'
user.groups = []
with user_set(pkgdb2.APP, user):
output = self.app.post(
'/acl/guake/request/commit/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="error">You must be a packager to apply to the '
'ACL: commit on guake</li>'
in output.data)
output = self.app.post(
'/acl/guake/request/watchcommits/',
data=data, follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="message">ACL watchcommits requested on branch '
'f18</li>' in output.data)
self.assertTrue(
'<li class="message">ACL watchcommits requested on branch '
'master</li>' in output.data)
示例10: test_api_package_unretire
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_api_package_unretire(self, login_func, mock_func):
""" Test the api_package_unretire function. """
login_func.return_value = None
# Redirect as you are not a packager
user = FakeFasUser()
user.groups = []
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/unretire/')
self.assertEqual(output.status_code, 302)
user = FakeFasUser()
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/unretire/')
self.assertEqual(output.status_code, 500)
data = json.loads(output.data)
self.assertEqual(
data,
{
"error": "Invalid input submitted",
"error_detail": [
"pkgnames: This field is required.",
"branches: This field is required.",
],
"output": "notok"
}
)
data = {
'pkgnames': 'guake',
'branches': ['f18', 'master'],
'poc': 'test',
}
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/unretire/', data=data)
self.assertEqual(output.status_code, 500)
data = json.loads(output.data)
self.assertEqual(
data,
{
"error": "No package found by this name",
"output": "notok"
}
)
create_package_acl(self.session)
mock_func.log.return_value = ''
# User is not an admin
data = {
'pkgnames': 'guake',
'branches': ['f18', 'master'],
}
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/unretire/', data=data)
self.assertEqual(output.status_code, 500)
data = json.loads(output.data)
self.assertEqual(
data,
{
"error": "You are not allowed to update the status of "
"the package: guake on branch f18 to "
"Approved.",
"output": "notok"
}
)
# Unretire the package
user = FakeFasUserAdmin()
data = {
'pkgnames': 'guake',
'branches': ['f18', 'master'],
}
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/unretire/', data=data)
self.assertEqual(output.status_code, 200)
data = json.loads(output.data)
self.assertEqual(
data,
{
"messages": ["", ""],
"output": "ok"
}
)
示例11: test_api_package_unorphan
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_api_package_unorphan(self, login_func, mock_func):
""" Test the api_package_unorphan function. """
login_func.return_value = None
# Redirect as you are not a packager
user = FakeFasUser()
user.groups = []
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/unorphan/')
self.assertEqual(output.status_code, 302)
user = FakeFasUser()
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/unorphan/')
self.assertEqual(output.status_code, 500)
data = json.loads(output.data)
self.assertEqual(
data,
{
"error": "Invalid input submitted",
"error_detail": [
"pkgnames: This field is required.",
"branches: This field is required.",
"poc: This field is required.",
],
"output": "notok"
}
)
mock_func.get_packagers.return_value = ['test']
data = {
'pkgnames': 'guake',
'branches': ['f18', 'master'],
'poc': 'test',
}
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/unorphan/', data=data)
self.assertEqual(output.status_code, 500)
data = json.loads(output.data)
self.assertEqual(
data,
{
"error": "No package found by this name",
"output": "notok"
}
)
create_package_acl(self.session)
mock_func.log.return_value = ''
# Unorphan a not-orphaned package
data = {
'pkgnames': 'guake',
'branches': ['f18', 'master'],
'poc': 'test',
}
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/unorphan/', data=data)
self.assertEqual(output.status_code, 500)
data = json.loads(output.data)
self.assertEqual(
data,
{
"error": "Package \"guake\" is not orphaned on f18",
"output": "notok"
}
)
# Orphan the package
data = {
'pkgnames': 'guake',
'branches': ['f18', 'master'],
'poc': 'test',
}
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/orphan/', data=data)
self.assertEqual(output.status_code, 200)
data = json.loads(output.data)
self.assertEqual(
data,
{
"messages": ["", ""],
"output": "ok"
}
)
pkg_acl = pkgdblib.get_acl_package(self.session, 'guake')
self.assertEqual(pkg_acl[0].collection.branchname, 'f18')
self.assertEqual(pkg_acl[0].package.name, 'guake')
self.assertEqual(pkg_acl[0].point_of_contact, 'orphan')
self.assertEqual(pkg_acl[0].status, 'Orphaned')
self.assertEqual(pkg_acl[1].collection.branchname, 'master')
self.assertEqual(pkg_acl[1].package.name, 'guake')
self.assertEqual(pkg_acl[1].point_of_contact, 'orphan')
self.assertEqual(pkg_acl[1].status, 'Orphaned')
# Unorphan the package for someone else
data = {
#.........这里部分代码省略.........
示例12: test_api_package_orphan
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_api_package_orphan(self, login_func, mock_func):
""" Test the api_package_orphan function. """
login_func.return_value = None
# Redirect as you are not a packager
user = FakeFasUser()
user.groups = []
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/orphan/')
self.assertEqual(output.status_code, 302)
user = FakeFasUser()
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/orphan/')
self.assertEqual(output.status_code, 500)
data = json.loads(output.data)
self.assertEqual(
data,
{
"error": "Invalid input submitted",
"error_detail": [
"pkgnames: This field is required.",
"branches: This field is required.",
],
"output": "notok"
}
)
data = {
'pkgnames': 'guake',
'branches': ['f18', 'master'],
'poc': 'test',
}
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/orphan/', data=data)
self.assertEqual(output.status_code, 500)
data = json.loads(output.data)
self.assertEqual(
data,
{
"error": "No package found by this name",
"output": "notok"
}
)
create_package_acl(self.session)
mock_func.log.return_value = ''
data = {
'pkgnames': 'guake',
'branches': ['f18', 'master'],
'poc': 'test',
}
with user_set(pkgdb2.APP, user):
output = self.app.post('/api/package/orphan/', data=data)
self.assertEqual(output.status_code, 200)
data = json.loads(output.data)
self.assertEqual(
data,
{
"messages": ["", ""],
"output": "ok"
}
)
pkg_acl = pkgdblib.get_acl_package(self.session, 'guake')
self.assertEqual(pkg_acl[0].collection.branchname, 'f18')
self.assertEqual(pkg_acl[0].package.name, 'guake')
self.assertEqual(pkg_acl[0].point_of_contact, 'orphan')
self.assertEqual(pkg_acl[0].status, 'Orphaned')
self.assertEqual(pkg_acl[1].collection.branchname, 'master')
self.assertEqual(pkg_acl[1].package.name, 'guake')
self.assertEqual(pkg_acl[1].point_of_contact, 'orphan')
self.assertEqual(pkg_acl[1].status, 'Orphaned')
示例13: test_request_acl
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_request_acl(self, login_func):
""" Test the request_acl function. """
login_func.return_value = None
create_package_acl(self.session)
user = FakeFasUser()
with user_set(pkgdb2.APP, user):
output = self.app.get('/acl/guake/request/')
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Request ACLs on package: guake</h1>' in output.data)
self.assertTrue(
'<input id="csrf_token" name="csrf_token"' in output.data)
self.assertTrue(
'<option value="approveacls">approveacls' in output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'pkg_branch': 'devel',
'pkg_acl': 'watchbugzilla',
'csrf_token': csrf_token,
}
output = self.app.post('/acl/guake/request/', data=data,
follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue('<li class="message">ACLs updated</li>' in
output.data)
user = FakeFasUser()
user.groups = ['gitr2spec']
with user_set(pkgdb2.APP, user):
output = self.app.get('/acl/guake/request/')
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Request ACLs on package: guake</h1>' in output.data)
self.assertTrue(
'<input id="csrf_token" name="csrf_token"' in output.data)
self.assertTrue(
'<option value="approveacls">approveacls' in output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'pkg_branch': 'devel',
'pkg_acl': 'commit',
'csrf_token': csrf_token,
}
output = self.app.post('/acl/guake/request/', data=data,
follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="message">ACLs updated</li>' in output.data)
self.assertTrue(
'<li class="errors">You must be a packager to apply to the '
'ACL: commit on devel</li>' in output.data)
user = FakeFasUser()
with user_set(pkgdb2.APP, user):
output = self.app.get('/acl/test/request/')
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Request ACLs on package: test</h1>' in output.data)
self.assertTrue(
'<input id="csrf_token" name="csrf_token"' in output.data)
self.assertTrue(
'<option value="approveacls">approveacls' in output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'pkg_branch': 'devel',
'pkg_acl': 'commit',
'csrf_token': csrf_token,
}
output = self.app.post('/acl/test/request/', 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)
示例14: test_update_acl
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_update_acl(self, login_func):
""" Test the update_acl function. """
login_func.return_value = None
create_package_acl(self.session)
user = FakeFasUser()
with user_set(pkgdb2.APP, user):
output = self.app.get(
'/acl/guake/update/pingou/', follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Update ACLs on package: guake</h1>' in output.data)
self.assertTrue(
'<input id="csrf_token" name="csrf_token"' in output.data)
self.assertTrue(
'<option value="approveacls">approveacls' in output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'pkg_branch': 'devel',
'pkg_acl': 'commit',
'acl_status': 'Approved',
'csrf_token': csrf_token,
}
output = self.app.post(
'/acl/guake/update/pingou/', data=data,
follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="message">ACLs updated</li>' in output.data)
user = FakeFasUser()
with user_set(pkgdb2.APP, user):
output = self.app.get(
'/acl/guake/update/test/', follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Update ACLs on package: guake</h1>' in output.data)
self.assertTrue(
'No pending ACLs for this user on this package.'
in output.data)
user = FakeFasUser()
user.groups = ['gitr2spec']
with user_set(pkgdb2.APP, user):
output = self.app.get(
'/acl/guake/update/toshio/devel', follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Update ACLs on package: guake</h1>' in output.data)
self.assertTrue(
'<input id="csrf_token" name="csrf_token"' in output.data)
self.assertTrue(
'<option value="approveacls">approveacls' in output.data)
user = FakeFasUser()
with user_set(pkgdb2.APP, user):
output = self.app.get(
'/acl/guake/update/pingou/', follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<h1>Update ACLs on package: guake</h1>' in output.data)
csrf_token = output.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
data = {
'pkg_branch': 'devel',
'pkg_acl': 'watchbugzilla',
'acl_status': 'Awaiting Review',
'csrf_token': csrf_token,
}
output = self.app.post(
'/acl/guake/update/pingou/', data=data,
follow_redirects=True)
self.assertEqual(output.status_code, 200)
self.assertTrue(
'<li class="message">ACLs updated</li>' in output.data)
示例15: test_unorphan_package
# 需要导入模块: from tests import FakeFasUser [as 别名]
# 或者: from tests.FakeFasUser import groups [as 别名]
def test_unorphan_package(self):
""" Test the unorphan_package function. """
create_package_acl(self.session)
# Wrong package name
self.assertRaises(pkgdblib.PkgdbException,
pkgdblib.unorphan_package,
self.session,
pkg_name='asd',
clt_name='devel',
pkg_user='pingou',
user=FakeFasUser()
)
# Wrong collection
self.assertRaises(pkgdblib.PkgdbException,
pkgdblib.unorphan_package,
self.session,
pkg_name='guake',
clt_name='asd',
pkg_user='pingou',
user=FakeFasUser()
)
# Package is not orphaned
self.assertRaises(pkgdblib.PkgdbException,
pkgdblib.unorphan_package,
self.session,
pkg_name='guake',
clt_name='devel',
pkg_user='pingou',
user=FakeFasUser()
)
# Orphan package
pkgdblib.update_pkg_poc(self.session,
pkg_name='guake',
clt_name='devel',
user=FakeFasUserAdmin(),
pkg_poc='orphan',
)
# User cannot unorphan for someone else
self.assertRaises(pkgdblib.PkgdbException,
pkgdblib.unorphan_package,
self.session,
pkg_name='guake',
clt_name='devel',
pkg_user='ralph',
user=FakeFasUser()
)
# User must be a packager
user = FakeFasUser()
user.groups = ['cla_done']
self.assertRaises(pkgdblib.PkgdbException,
pkgdblib.unorphan_package,
self.session,
pkg_name='guake',
clt_name='devel',
pkg_user='pingou',
user=user
)
pkg_acl = pkgdblib.get_acl_package(self.session, 'guake')
self.assertEqual(pkg_acl[1].collection.branchname, 'devel')
self.assertEqual(pkg_acl[1].package.name, 'guake')
self.assertEqual(pkg_acl[1].point_of_contact, 'orphan')
self.assertEqual(pkg_acl[1].status, 'Orphaned')
pkgdblib.unorphan_package(
self.session,
pkg_name='guake',
clt_name='devel',
pkg_user='pingou',
user=FakeFasUser()
)
pkg_acl = pkgdblib.get_acl_package(self.session, 'guake')
self.assertEqual(pkg_acl[1].collection.branchname, 'devel')
self.assertEqual(pkg_acl[1].package.name, 'guake')
self.assertEqual(pkg_acl[1].point_of_contact, 'pingou')
self.assertEqual(pkg_acl[1].status, 'Approved')