def __init__(self, config): matplotlib.use('Agg') RESTFormatter.__init__(self, config) self.supporttypes = {'image/png': self.png, '*/*': self.png, 'application/pdf': self.pdf, 'image/svg+xml':self.svg}
def __init__(self, config): "Initialise the formatter and set the mime types it supports" RESTFormatter.__init__(self, config) mimes = { 'text/json+das': self.dasjson, 'application/xml+das': self.xml, 'application/plist': self.plist } self.supporttypes.update(mimes)
def __init__(self, config): RESTFormatter.__init__(self, config) self.supporttypes = {'application/xml': self.xml, 'application/atom+xml': self.atom, 'text/json': self.json, 'text/x-json': self.json, 'application/json': self.json, 'text/html': self.to_string, 'text/plain': self.to_string, '*/*': self.json}
def __init__(self, config): matplotlib.use('Agg') RESTFormatter.__init__(self, config) self.supporttypes = { 'image/png': self.png, '*/*': self.png, 'application/pdf': self.pdf, 'image/svg+xml': self.svg }
def testGenerator(self): rf = RESTFormatter(config=self.config.Webtools) url = self.urlbase +'gen' # gen method from DummyRESTModel will return this generator gen = ({'idx':i} for i in range(10)) # the WMCore should convert it into list regardless of accept type data = rf.json(gen) methodTest('GET', url, accept='application/json', output={'code':200, 'data':data}) methodTest('GET', url, accept='*/*', output={'code':200, 'data':data})
def testSupportedFormat(self): rf = RESTFormatter(config=self.config.Webtools) url = self.urlbase +'list1/' for type in rf.supporttypes.keys(): # test accepted type should return 200 error methodTest('GET', url, accept=type, output={'code':200})
def __init__(self, config): "Initialise the formatter and set the mime types it supports" RESTFormatter.__init__(self, config) mimes = {'text/json+das':self.dasjson, 'application/xml+das':self.xml, 'application/plist':self.plist} self.supporttypes.update(mimes)