IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 23, 2010, 3:38:03 PM (16 years ago)
Author:
Serge CHASTEL
Message:

Test report / product

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sc_branches/psps_testing/psi/psi_inquisitor.py

    r29140 r29227  
    22from suds.xsd.doctor import Import, ImportDoctor
    33from suds import sudsobject
    4 from utilities.util import convert
     4from utilities.util import psi_convert
    55import unicodedata
     6from utilities.psps_logger import PsPsLogger
     7from utilities.test_report import TestReport
    68
    79class PsiInquisitor:
     
    2426        # exec 'from %s import Configuration' % configuration_file
    2527        # self.configuration = Configuration
     28        PsPsLogger.debug('Creating PsiInquisitor from %s file' % configuration_file)
    2629        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())
    2833        self.authClient = Client(self.configuration.authUrl)
    2934        self.sessionID = self.authClient.service.login(self.configuration.userID,
     
    3944        Make a query in the fast queue.
    4045       
     46        >>> psiInquisitor = PsiInquisitor('psi.web01_configuration')
    4147        >>> query = 'select frameID from FrameMeta where frameID=105439;'
    42         >>> psiInquisitor = PsiInquisitor('psi.web01_configuration')
    4348        >>> result = psiInquisitor.query(query)
    4449        >>> # we cannot guarantee the order in result
     
    4954        >>> print result['types']
    5055        {'[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
    51102        >>> # This test has to be completed with exhaustive ones...
    52103        >>> # e.g. unit tests against the csr data base.
    53104        """
     105        PsPsLogger.debug('Querying PSI: [%s]' % sql_query)
    54106        results = self.jobsClient.service.executeQuickJob(self.sessionID,
    55107                                                          self.configuration.schemaGroup,
     
    94146                                                               '').replace(']',
    95147                                                                           '')
    96                     element[field_name] = convert(types_dictionary[contents['fields'][i]],
     148                    element[field_name] = psi_convert(types_dictionary[contents['fields'][i]],
    97149                                                  values[i])
    98150                contents['items'].append(element)
     151        PsPsLogger.debug('Number of answers: %d' % len(contents['items']))
    99152        return contents
    100153
    101154if __name__ == '__main__':
     155    import logging
     156    PsPsLogger.set_stderr()
     157    PsPsLogger.setLevel(logging.DEBUG)
    102158    import doctest
    103159    doctest.testmod()
Note: See TracChangeset for help on using the changeset viewer.