예제 #1
0
class Query(APIOperation):
    '''
    classdocs
    '''
    def __init__(self):
        self.api = DataAPI()
        self.cr = CReader('../APIInterface/sampledata')

    def probe(self):
        self.api.connect()
        self.api.dispReq(self.api.req)
        self.api.dispRes(self.api.res)
예제 #2
0
파일: Main.py 프로젝트: josephramsay/LDSAPI
class Query(APIOperation):
    '''
    classdocs
    '''


    def __init__(self):
        self.api = DataAPI()
        self.cr = CReader('../APIInterface/sampledata')
    
    def probe(self):
        self.api.connect()
        self.api.dispReq(self.api.req)
        self.api.dispRes(self.api.res)
예제 #3
0
 def __init__(self):
     self.api = DataAPI()
     self.cr = CReader('../APIInterface/sampledata')
예제 #4
0
 def setUp(self):
     print 'D'#\n----------------------------------\n'
     self.api = DataAPI(FileReader.creds,self.cdir+self.cfile)
     self.api.setParams()
예제 #5
0
class DataTester(APITestCase):
    
    avoid = ['dpu_draftversion','ddl_delete']
    
    def setUp(self):
        print 'D'#\n----------------------------------\n'
        self.api = DataAPI(FileReader.creds,self.cdir+self.cfile)
        self.api.setParams()
        
    def tearDown(self):
        self.api = None
        
    #basic connect
    
    def test_10_ReadBaseData(self):
        self.api.connect()
        self.api.dispRes(self.api.res)
    
    #parameter sets test
    
        
    def test_20_DataAPI_list(self):
        sec='list'
        for pth in self.api.data_path[sec].keys():
            print '*** Data API section={} key={} ***'.format(sec,str(pth))
            self.api.setParams(s=sec,p=pth)
            self.api.connect('?format={}'.format(FMT))
            print '*** {}'.format(self.api.req.get_full_url())
            self.outputRes(self.api.res.read())    
            
    def test_30_DataAPI_detail(self):
        sec = 'detail'
        for pth in self.api.data_path[sec].keys():
            if pth in self.avoid: continue
            print '*** Data API section={} key={} ***'.format(sec,str(pth))
            self.api.setParams(s=sec,p=pth,id=ID)
            self.api.connect('?format={}'.format(FMT))
            print '*** {}'.format(self.api.req.get_full_url())
            self.outputRes(self.api.res.read())    
             
    def test_40_DataAPI_version(self):
        sec = 'version'
        for pth in self.api.data_path[sec].keys():
            if pth in self.avoid: continue
            print '*** Data API section={} key={} ***'.format(sec,str(pth))
            self.api.setParams(s=sec,p=pth,id=ID,version=VER)
            self.api.connect('?format={}'.format(FMT))
            print '*** {}'.format(self.api.req.get_full_url())
            self.outputRes(self.api.res.read())
             
#     def test_50_DataAPI_publish(self):
#         sec = 'publish'
#         for pth in self.api.data_path[sec].keys():
#             if pth in self.avoid: continue
#             print '*** Data API section={} key={} ***'.format(sec,str(pth))
#             self.api.setParams(s=sec,p=pth,id=ID)
#             self.api.connect('?format=json')
#             print '*** {}'.format(self.api.req.get_full_url())
#             self.outputRes(self.api.res.read())
             
    def test_60_DataAPI_metadata(self):
        sec = 'metadata'
        for pth in self.api.data_path[sec].keys():
            if pth in self.avoid: continue
            print '*** Data API section={} key={} ***'.format(sec,str(pth))
            self.api.setParams(s=sec,p=pth,id=ID,version=VER,type=TYP)
            self.api.connect('?format={}'.format(FMT))
            print '*** {}'.format(self.api.req.get_full_url())
            self.outputRes(self.api.res.read())
        
  

    def outputRes(self,res):
        be = json.loads(res)
        print 'JSON - start'
        if isinstance(be, dict):
            self.outputFeat(be)
        else:
            for l in be: self.outputFeat(l)
        print 'JSON - end'
        
    def outputFeat(self,feat):
        print 'name:{} - id:{} type:{} published:{}'.format(feat['name'],feat['id'],feat['type'],feat['published_at'])    
예제 #6
0
파일: Main.py 프로젝트: josephramsay/LDSAPI
 def __init__(self):
     self.api = DataAPI()
     self.cr = CReader('../APIInterface/sampledata')
예제 #7
0
 def setUp(self):
     print('D')  #\n----------------------------------\n'
     self.api = DataAPI(FileReader.creds, self.cdir + self.cfile)
     self.api.setParams()
예제 #8
0
class DataTester(APITestCase):

    avoid = ['dpu_draftversion', 'ddl_delete']

    def setUp(self):
        print('D')  #\n----------------------------------\n'
        self.api = DataAPI(FileReader.creds, self.cdir + self.cfile)
        self.api.setParams()

    def tearDown(self):
        self.api = None

    #basic connect

    def test_10_ReadBaseData(self):
        self.api.connect()
        self.api.dispRes(self.api.res)

    #parameter sets test

    def test_20_DataAPI_list(self):
        sec = 'list'
        for pth in list(self.api.data_path[sec].keys()):
            print('*** Data API section={} key={} ***'.format(sec, str(pth)))
            self.api.setParams(s=sec, p=pth)
            self.api.connect('?format={}'.format(FMT))
            print('*** {}'.format(self.api.req.get_full_url()))
            self.outputRes(self.api.res.read())

    def test_30_DataAPI_detail(self):
        sec = 'detail'
        for pth in list(self.api.data_path[sec].keys()):
            if pth in self.avoid: continue
            print('*** Data API section={} key={} ***'.format(sec, str(pth)))
            self.api.setParams(s=sec, p=pth, id=ID)
            self.api.connect('?format={}'.format(FMT))
            print('*** {}'.format(self.api.req.get_full_url()))
            self.outputRes(self.api.res.read())

    def test_40_DataAPI_version(self):
        sec = 'version'
        for pth in list(self.api.data_path[sec].keys()):
            if pth in self.avoid: continue
            print('*** Data API section={} key={} ***'.format(sec, str(pth)))
            self.api.setParams(s=sec, p=pth, id=ID, version=VER)
            self.api.connect('?format={}'.format(FMT))
            print('*** {}'.format(self.api.req.get_full_url()))
            self.outputRes(self.api.res.read())


#     def test_50_DataAPI_publish(self):
#         sec = 'publish'
#         for pth in self.api.data_path[sec].keys():
#             if pth in self.avoid: continue
#             print '*** Data API section={} key={} ***'.format(sec,str(pth))
#             self.api.setParams(s=sec,p=pth,id=ID)
#             self.api.connect('?format=json')
#             print '*** {}'.format(self.api.req.get_full_url())
#             self.outputRes(self.api.res.read())

    def test_60_DataAPI_metadata(self):
        sec = 'metadata'
        for pth in list(self.api.data_path[sec].keys()):
            if pth in self.avoid: continue
            print('*** Data API section={} key={} ***'.format(sec, str(pth)))
            self.api.setParams(s=sec, p=pth, id=ID, version=VER, type=TYP)
            self.api.connect('?format={}'.format(FMT))
            print('*** {}'.format(self.api.req.get_full_url()))
            self.outputRes(self.api.res.read())

    def outputRes(self, res):
        be = json.loads(res)
        print('JSON - start')
        if isinstance(be, dict):
            self.outputFeat(be)
        else:
            for l in be:
                self.outputFeat(l)
        print('JSON - end')

    def outputFeat(self, feat):
        print('name:{} - id:{} type:{} published:{}'.format(
            feat['name'], feat['id'], feat['type'], feat['published_at']))