API: add a is_user_member_of() function
This commit is contained in:
parent
35f5a7b5e1
commit
69e1771a11
@ -27,6 +27,7 @@ from osc import conf
|
|||||||
from osc import oscerr
|
from osc import oscerr
|
||||||
from osc.core import change_review_state
|
from osc.core import change_review_state
|
||||||
from osc.core import delete_package
|
from osc.core import delete_package
|
||||||
|
from osc.core import get_group
|
||||||
from osc.core import get_request
|
from osc.core import get_request
|
||||||
from osc.core import make_meta_url
|
from osc.core import make_meta_url
|
||||||
from osc.core import makeurl
|
from osc.core import makeurl
|
||||||
@ -58,6 +59,7 @@ class StagingAPI(object):
|
|||||||
self.crebuild = conf.config[project]['rebuild']
|
self.crebuild = conf.config[project]['rebuild']
|
||||||
self.cproduct = conf.config[project]['product']
|
self.cproduct = conf.config[project]['product']
|
||||||
self.copenqa = conf.config[project]['openqa']
|
self.copenqa = conf.config[project]['openqa']
|
||||||
|
self.user = conf.get_apiurl_usr(apiurl)
|
||||||
|
|
||||||
# If the project support rings, inititialize some variables.
|
# If the project support rings, inititialize some variables.
|
||||||
self.ring_packages = {}
|
self.ring_packages = {}
|
||||||
@ -1148,3 +1150,11 @@ class StagingAPI(object):
|
|||||||
http_PUT(url, data=meta)
|
http_PUT(url, data=meta)
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
def is_user_member_of(self, user, group):
|
||||||
|
root = ET.fromstring(get_group(self.apiurl, group))
|
||||||
|
|
||||||
|
if root.findall("./person/person[@userid='%s']" % user):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
7
tests/fixtures/group/factory-staging
vendored
Normal file
7
tests/fixtures/group/factory-staging
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<group>
|
||||||
|
<title>factory-staging</title>
|
||||||
|
<person>
|
||||||
|
<person userid="Admin"/>
|
||||||
|
</person>
|
||||||
|
</group>
|
||||||
|
|
@ -25,7 +25,7 @@ import httpretty
|
|||||||
import osc
|
import osc
|
||||||
|
|
||||||
|
|
||||||
APIURL = 'https://localhost'
|
APIURL = 'http://localhost'
|
||||||
|
|
||||||
FIXTURES = os.path.join(os.getcwd(), 'tests/fixtures')
|
FIXTURES = os.path.join(os.getcwd(), 'tests/fixtures')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user