本文整理汇总了Python中WMCore.Services.Requests.JSONRequests.delete方法的典型用法代码示例。如果您正苦于以下问题:Python JSONRequests.delete方法的具体用法?Python JSONRequests.delete怎么用?Python JSONRequests.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Services.Requests.JSONRequests
的用法示例。
在下文中一共展示了JSONRequests.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReqMgrTest
# 需要导入模块: from WMCore.Services.Requests import JSONRequests [as 别名]
# 或者: from WMCore.Services.Requests.JSONRequests import delete [as 别名]
#.........这里部分代码省略.........
"outputModules_": ["ThisIsAName"],
"ThisIsAName": {"dataset": {"dataTier": "RECO", "filterName": "Filter"}},
}
}
BadTweak = {
"process": {
"outputModules_": ["ThisIsAName1", "ThisIsAName2"],
"ThisIsAName1": {"dataset": {"dataTier": "RECO", "filterName": "Filter"}},
"ThisIsAName2": {"dataset": {"dataTier": "RECO", "filterName": "Filter"}},
}
}
configCache = ConfigCache(os.environ["COUCHURL"], couchDBName=self.couchDBName)
configCache.createUserGroup(groupname="testGroup", username="testOps")
if bad:
configCache.setPSetTweaks(PSetTweak=BadTweak)
else:
configCache.setPSetTweaks(PSetTweak=PSetTweak)
configCache.save()
return configCache.getCouchID()
@attr("integration")
def testA_testBasicSetUp(self):
"""
_testBasicSetUp_
Moving the tests that were in the setUp category out of it,
mostly because I want to make sure that they don't fail inside
the setUp statement.
"""
if "me" in self.jsonSender.get("user")[0]:
self.jsonSender.delete("user/me")
self.assertFalse("me" in self.jsonSender.get("user")[0])
self.assertEqual(self.jsonSender.put("user/[email protected]")[1], 200)
self.assertTrue("me" in self.jsonSender.get("user")[0])
if "PeopleLikeMe" in self.jsonSender.get("group")[0]:
self.jsonSender.delete("group/PeopleLikeMe")
self.assertFalse("PeopleLikeMe" in self.jsonSender.get("group")[0])
self.assertEqual(self.jsonSender.put("group/PeopleLikeMe")[1], 200)
self.assertTrue("PeopleLikeMe" in self.jsonSender.get("group")[0])
self.jsonSender.put("group/PeopleLikeMe/me")
users = self.jsonSender.get("group/PeopleLikeMe")[0]["users"]
self.assertTrue("me" in users)
groups = self.jsonSender.get("user/me")[0]["groups"]
self.assertTrue("PeopleLikeMe" in groups)
groups2 = self.jsonSender.get("group?user=me")[0]
self.assertTrue("PeopleLikeMe" in groups2)
if "White Sox" in self.jsonSender.get("team")[0]:
self.jsonSender.delete(urllib.quote("team/White Sox"))
self.assertFalse("White Sox" in self.jsonSender.get("team")[0])
self.assertEqual(self.jsonSender.put(urllib.quote("team/White Sox"))[1], 200)
self.assertTrue("White Sox" in self.jsonSender.get("team")[0])
# some foreign key stuff to dealwith
self.assertTrue(self.jsonSender.put("version/CMSSW_3_5_8")[1] == 200)
self.assertTrue("CMSSW_3_5_8" in self.jsonSender.get("version")[0])
return
@attr("integration")
def testB_ReReco(self):
"""
示例2: TestReqMgr
# 需要导入模块: from WMCore.Services.Requests import JSONRequests [as 别名]
# 或者: from WMCore.Services.Requests.JSONRequests import delete [as 别名]
class TestReqMgr(RESTBaseUnitTest):
"""
_TestReqMgr_
Basic test for the ReqMgr services
"""
def initialize(self):
self.config = RequestManagerConfig(
'WMCore.HTTPFrontEnd.RequestManager.ReqMgrRESTModel')
dbUrl = os.environ.get("DATABASE", None)
if dbUrl == None:
raise RuntimeError, """The DATABASE environment is not set. WARNING: setting this variable will cause the database to be deleted during cleanup! """
self.config.setDBUrl(dbUrl)
self.config.setFormatter('WMCore.WebTools.RESTFormatter')
self.config.setupRequestConfig()
# mysql example
#self.config.setDBUrl('mysql://[email protected]:3306/TestDB')
#self.config.setDBSocket('/var/lib/mysql/mysql.sock')
self.schemaModules = ["WMCore.RequestManager.RequestDB"]
# Do this is you don't want to remake and delete the schema
#self.schemaModules = []
def setUp(self):
"""
setUP global values
"""
RESTBaseUnitTest.setUp(self)
reqMgrHost = self.config.getServerUrl()
self.requestSchema = getRequestSchema()
print reqMgrHost
self.jsonSender = JSONRequests(reqMgrHost)
#self.requestTypes = ['ReReco', 'StoreResults', 'CmsGen', 'Reco']
#self.requestTypes = ['ReReco', 'MonteCarlo']
self.requestTypes = ['ReReco']
if 'me' in self.jsonSender.get('user')[0]:
self.jsonSender.delete('user/me')
self.assertFalse('me' in self.jsonSender.get('user')[0])
self.assertEqual(self.jsonSender.put('user/[email protected]')[1], 200)
self.assertTrue('me' in self.jsonSender.get('user')[0])
if 'PeopleLikeMe' in self.jsonSender.get('group')[0]:
self.jsonSender.delete('group/PeopleLikeMe')
self.assertFalse('PeopleLikeMe' in self.jsonSender.get('group')[0])
self.assertEqual(self.jsonSender.put('group/PeopleLikeMe')[1], 200)
self.assertTrue( 'PeopleLikeMe' in self.jsonSender.get('group')[0])
self.jsonSender.put('group/PeopleLikeMe/me')
users = json.loads(self.jsonSender.get('group/PeopleLikeMe')[0])['users']
self.assertTrue('me' in users)
groups = json.loads(self.jsonSender.get('user/me')[0])['groups']
self.assertTrue('PeopleLikeMe' in groups)
groups2 = self.jsonSender.get('group?user=me')[0]
self.assertTrue('PeopleLikeMe' in groups2)
if 'White Sox' in self.jsonSender.get('team')[0]:
self.jsonSender.delete(urllib.quote('team/White Sox'))
self.assertFalse('White Sox' in self.jsonSender.get('team')[0])
self.assertEqual(self.jsonSender.put(urllib.quote('team/White Sox'))[1], 200)
self.assertTrue('White Sox' in self.jsonSender.get('team')[0])
# some foreign key stuff to dealwith
#self.assertFalse('CMSSW_X_Y_Z' in self.jsonSender.get('version')[0])
self.assertTrue(self.jsonSender.put('version/CMSSW_3_5_8')[1] == 200)
self.assertTrue('CMSSW_3_5_8' in self.jsonSender.get('version')[0])
@attr("integration")
def testReReco(self):
schema = ReReco.getTestArguments()
schema['RequestName'] = 'TestReReco'
schema['RequestType'] = 'ReReco'
schema['CmsPath'] = "/uscmst1/prod/sw/cms"
self.doRequest(schema)
def doRequest(self, schema):
schema['CmsPath'] = "/uscmst1/prod/sw/cms"
schema['Requestor'] = 'me'
schema['Group'] = 'PeopleLikeMe'
requestName = schema['RequestName']
self.assertRaises(HTTPException, self.jsonSender.delete, 'request/%s' % requestName)
self.assertEqual(self.jsonSender.put('request/%s' % requestName, schema)[1], 200)
self.assertEqual(self.jsonSender.get('request/%s' % requestName)[0]['RequestName'], requestName)
self.assertTrue(requestName in self.jsonSender.get('user/me')[0])
self.jsonSender.put('request/%s?status=assignment-approved' % requestName)
meJSON = self.jsonSender.get('user/me')[0]
me = json.loads(meJSON)
self.assertTrue(requestName in me['requests'])
self.assertEqual(self.jsonSender.put('request/%s?priority=5' % requestName)[1], 200)
self.assertEqual(self.jsonSender.post('user/me?priority=6')[1], 200)
self.assertEqual(self.jsonSender.post('group/PeopleLikeMe?priority=7')[1], 200)
# default priority of group and user of 1
request = self.jsonSender.get('request/%s' % requestName)[0]
self.assertEqual(request['ReqMgrRequestBasePriority'], 5)
self.assertEqual(request['ReqMgrRequestorBasePriority'], 6)
self.assertEqual(request['ReqMgrGroupBasePriority'], 7)
self.assertEqual(request['RequestPriority'], 5+6+7)
#.........这里部分代码省略.........
示例3: ReqMgrTest
# 需要导入模块: from WMCore.Services.Requests import JSONRequests [as 别名]
# 或者: from WMCore.Services.Requests.JSONRequests import delete [as 别名]
class ReqMgrTest(RESTBaseUnitTest):
"""
Basic test for the ReqMgr services.
Setup is done off-screen in RESTBaseUnitTest - this makes
things confusing
"""
def setUp(self):
"""
setUP global values
Database setUp is done in base class
"""
self.couchDBName = "reqmgr_t_0"
RESTBaseUnitTest.setUp(self)
self.testInit.setupCouch("%s" % self.couchDBName, "ConfigCache", "ReqMgr")
self.testInit.setupCouch("%s_wmstats" % self.couchDBName,
"WMStats")
self.testInit.setupCouch("%s_acdc" % self.couchDBName,
"ACDC", "GroupUser")
reqMgrHost = self.config.getServerUrl()
self.jsonSender = JSONRequests(reqMgrHost)
self.params = {}
self.params['endpoint'] = reqMgrHost
self.reqService = RequestManager(self.params)
def initialize(self):
self.config = RequestManagerConfig(
'WMCore.HTTPFrontEnd.RequestManager.ReqMgrRESTModel')
self.config.setFormatter('WMCore.WebTools.RESTFormatter')
self.config.setupRequestConfig()
self.config.setupCouchDatabase(dbName = self.couchDBName)
self.config.setPort(12888)
self.schemaModules = ["WMCore.RequestManager.RequestDB"]
def tearDown(self):
"""
tearDown
Tear down everything
"""
RESTBaseUnitTest.tearDown(self)
self.testInit.tearDownCouch()
def createConfig(self, bad = False):
"""
_createConfig_
Create a config of some sort that we can load out of ConfigCache
"""
PSetTweak = {'process': {'outputModules_': ['ThisIsAName'],
'ThisIsAName': {'dataset': {'dataTier': 'RECO',
'filterName': 'Filter'}}}}
BadTweak = {'process': {'outputModules_': ['ThisIsAName1', 'ThisIsAName2'],
'ThisIsAName1': {'dataset': {'dataTier': 'RECO',
'filterName': 'Filter'}},
'ThisIsAName2': {'dataset': {'dataTier': 'RECO',
'filterName': 'Filter'}}}}
configCache = ConfigCache(os.environ["COUCHURL"], couchDBName = self.couchDBName)
configCache.createUserGroup(groupname = "testGroup", username = 'testOps')
if bad:
configCache.setPSetTweaks(PSetTweak = BadTweak)
else:
configCache.setPSetTweaks(PSetTweak = PSetTweak)
configCache.save()
return configCache.getCouchID()
@attr("integration")
def testA_testBasicSetUp(self):
"""
_testBasicSetUp_
Moving the tests that were in the setUp category out of it,
mostly because I want to make sure that they don't fail inside
the setUp statement.
"""
if 'me' in self.jsonSender.get('user')[0]:
self.jsonSender.delete('user/me')
self.assertFalse('me' in self.jsonSender.get('user')[0])
self.assertEqual(self.jsonSender.put('user/[email protected]')[1], 200)
self.assertTrue('me' in self.jsonSender.get('user')[0])
if 'PeopleLikeMe' in self.jsonSender.get('group')[0]:
self.jsonSender.delete('group/PeopleLikeMe')
self.assertFalse('PeopleLikeMe' in self.jsonSender.get('group')[0])
self.assertEqual(self.jsonSender.put('group/PeopleLikeMe')[1], 200)
self.assertTrue( 'PeopleLikeMe' in self.jsonSender.get('group')[0])
self.jsonSender.put('group/PeopleLikeMe/me')
users = self.jsonSender.get('group/PeopleLikeMe')[0]['users']
#.........这里部分代码省略.........
示例4: ReqMgrTester
# 需要导入模块: from WMCore.Services.Requests import JSONRequests [as 别名]
# 或者: from WMCore.Services.Requests.JSONRequests import delete [as 别名]
class ReqMgrTester(object):
def __init__(self, reqMgrUrl):
self.reqMgrUrl = reqMgrUrl
self.restSender = JSONRequests(reqMgrUrl)
d = dict(endpoint = self.reqMgrUrl)
self.reqMgrService = RequestManager(d)
def queryAllRequests(self):
"""
Returns all requests stored at ReqMgr instance.
"""
logging.info("Querying all requests at ReqMgr instance ...")
r = self.reqMgrService.getRequestNames()
print "Found %s requests:" % len(r)
for req in r:
print req
def queryRequest(self, requestName):
"""
Query a specific request according to the input argument.
"""
urlQuery = "request/%s" % requestName
logging.info("Querying request '%s'" % requestName)
logging.info("Query: '%s':" % urlQuery)
r = self.restSender.get(urlQuery)
print str(r)
def createRequests(self, numRequests):
"""
Inject new numRequests into ReqMgr instance.
(see ReqMgr_t testE how to create a request)
"""
logging.info("Creating %s new requests ..." % numRequests)
schema = ReReco.getTestArguments()
schema['RequestName'] = 'TestReReco'
schema['RequestType'] = 'ReReco'
schema['CmsPath'] = "/uscmst1/prod/sw/cms"
schema['Requestor'] = '%s' % "zmaxa"
schema['Group'] = '%s' % "DATAOPS"
schema['BlockWhitelist'] = ['/dataset/dataset/dataset#alpha']
schema['BlockBlacklist'] = ['/dataset/dataset/dataset#beta']
schema['Campaign'] = 'MyTestCampaign'
for i in range(numRequests):
urlQuery = "request/testRequest"
print "Query: '%s':" % urlQuery
print "Schema (request): '%s'" % schema
r = self.restSender.put(urlQuery, schema)
# print "request creating response: ", r
print "created: ", r[0]["RequestName"]
def deleteRequest(self, requestNames):
"""
Delete requests specified in the input, more request names
are comma-separated.
"""
logging.info("Deleting requests ...")
for reqName in requestNames.split(','):
reqName = reqName.strip()
urlQuery = "request/%s" % reqName
logging.info("Deleting request (request_name): '%s'" % reqName)
logging.info("Query: '%s':" % urlQuery)
r = self.restSender.delete(urlQuery)
def requestChangeStates(self, reqName):
"""
Route the request (spec. by the request name) in the input
through a series of possible request states.
"""
logging.info("Changing state of request %s ..." % reqName)
def changeState(requestName, urlQuery):
logging.info("Query: '%s' ..." % urlQuery)
r = self.restSender.put(urlQuery)
r = self.restSender.get("request/%s" % requestName)
#assert r[0]["RequestStatus"] == statusName
logging.info("Querying modified request, new state: %s" % r[0]["RequestStatus"])
# once a request is created, it's in 'new' state
# states transition has to be an allowed one as defined here:
# WMCore/RequestManager/RequestDB/Settings/RequestStatus.py
statesQueries = ["request/%s?status=%s" % (reqName, "testing-approved"),
"request/%s?status=%s" % (reqName, "testing"),
"request/%s?status=%s" % (reqName, "tested"),
"request/%s?status=%s" % (reqName, "assignment-approved"),
# create an assignment now
# need quote because of space in the team name
# (previous name - White Sox)
urllib.quote("assignment/%s/%s" % (TEAM_NAME, reqName))]
for query in statesQueries:
changeState(reqName, query)
#.........这里部分代码省略.........