Changeset 29227 for branches/sc_branches/psps_testing/psi/psi_inquisitor.py
- Timestamp:
- Sep 23, 2010, 3:38:03 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/sc_branches/psps_testing/psi/psi_inquisitor.py
r29140 r29227 2 2 from suds.xsd.doctor import Import, ImportDoctor 3 3 from suds import sudsobject 4 from utilities.util import convert4 from utilities.util import psi_convert 5 5 import unicodedata 6 from utilities.psps_logger import PsPsLogger 7 from utilities.test_report import TestReport 6 8 7 9 class PsiInquisitor: … … 24 26 # exec 'from %s import Configuration' % configuration_file 25 27 # self.configuration = Configuration 28 PsPsLogger.debug('Creating PsiInquisitor from %s file' % configuration_file) 26 29 self.configuration = __import__(configuration_file, globals(), locals(), 27 ['Configuration'], -1).Configuration 30 ['Configuration'], -1).PsiConfiguration 31 TestReport.info('PsiInquisitor created from %s' % configuration_file) 32 TestReport.info(self.configuration.str()) 28 33 self.authClient = Client(self.configuration.authUrl) 29 34 self.sessionID = self.authClient.service.login(self.configuration.userID, … … 39 44 Make a query in the fast queue. 40 45 46 >>> psiInquisitor = PsiInquisitor('psi.web01_configuration') 41 47 >>> query = 'select frameID from FrameMeta where frameID=105439;' 42 >>> psiInquisitor = PsiInquisitor('psi.web01_configuration')43 48 >>> result = psiInquisitor.query(query) 44 49 >>> # we cannot guarantee the order in result … … 49 54 >>> print result['types'] 50 55 {'[frameID]': 'Integer'} 56 57 >>> query = 'select surveyID from FrameMeta where frameID=105439;' 58 >>> result = psiInquisitor.query(query) 59 >>> # we cannot guarantee the order in result 60 >>> print result['items'] 61 [{'surveyID': 0}] 62 >>> print result['fields'] 63 ['[surveyID]'] 64 >>> print result['types'] 65 {'[surveyID]': 'Byte'} 66 67 >>> query = 'select cameraID from FrameMeta where frameID=105439;' 68 >>> result = psiInquisitor.query(query) 69 >>> # we cannot guarantee the order in result 70 >>> print result['items'] 71 [{'cameraID': 1}] 72 >>> print result['fields'] 73 ['[cameraID]'] 74 >>> print result['types'] 75 {'[cameraID]': 'Integer'} 76 >>> # It should be something expressing that it is a 16-bits integer 77 78 >>> # REAL 4 bytes 79 >>> query = 'select photoScat from FrameMeta where frameID=105439;' 80 >>> result = psiInquisitor.query(query) 81 >>> # we cannot guarantee the order in result 82 >>> print result['items'] 83 [{'photoScat': 0.051822260000000002}] 84 >>> print result['fields'] 85 ['[photoScat]'] 86 >>> print result['types'] 87 {'[photoScat]': 'Float'} 88 >>> # There should be sthg to make the difference between f32 and f64 89 90 >>> # FLOAT 8 bytes 91 >>> query = 'select expStart from FrameMeta where frameID=105439;' 92 >>> result = psiInquisitor.query(query) 93 >>> # we cannot guarantee the order in result 94 >>> print result['items'] 95 [{'expStart': 55163.4545890027}] 96 >>> print result['fields'] 97 ['[expStart]'] 98 >>> print result['types'] 99 {'[expStart]': 'Float'} 100 >>> # There should be sthg to make the difference between f32 and f64 101 51 102 >>> # This test has to be completed with exhaustive ones... 52 103 >>> # e.g. unit tests against the csr data base. 53 104 """ 105 PsPsLogger.debug('Querying PSI: [%s]' % sql_query) 54 106 results = self.jobsClient.service.executeQuickJob(self.sessionID, 55 107 self.configuration.schemaGroup, … … 94 146 '').replace(']', 95 147 '') 96 element[field_name] = convert(types_dictionary[contents['fields'][i]],148 element[field_name] = psi_convert(types_dictionary[contents['fields'][i]], 97 149 values[i]) 98 150 contents['items'].append(element) 151 PsPsLogger.debug('Number of answers: %d' % len(contents['items'])) 99 152 return contents 100 153 101 154 if __name__ == '__main__': 155 import logging 156 PsPsLogger.set_stderr() 157 PsPsLogger.setLevel(logging.DEBUG) 102 158 import doctest 103 159 doctest.testmod()
Note:
See TracChangeset
for help on using the changeset viewer.
