NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

Changeset 253

Show
Ignore:
Timestamp:
11/19/09 17:37:10
Author:
cbc
Message:

Completed test refactoring. 100% test coverage.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sodar/branches/scintec-branch/setup.py

    r239 r253  
    33Installer for sodar package. 
    44""" 
     5 
     6__author__ = 'Chris Calloway' 
     7__email__ = 'cbc@chriscalloway.org' 
     8__copyright__ = 'Copyright 2009 UNC-CH Department of Marine Science' 
     9__license__ = 'GPL2' 
    510 
    611from setuptools import setup, find_packages 
     
    3439      entry_points=""" 
    3540      """, 
     41      test_suite='sodar.tests.suite.test_suite', 
    3642     ) 
  • sodar/branches/scintec-branch/sodar/scintec/maindata.py

    r251 r253  
    11""" 
    22Module to handle Scintec sodar .mnd files. 
     3 
     4>>> from sodar.scintec import maindata 
    35""" 
    46 
     
    1618    Parse the format header: 
    1719     
    18     >>> main_data = MainData(_testSetUp('good','091117.mnd')
    19     >>> main_data.format_header[0] 
     20    >>> main_data = MainData(good_mnd
     21    >>> main_data._format_header[0] 
    2022    'FORMAT-1' 
    2123    """ 
     
    2931        Where mnd is a str object containing the complete contents read from a 
    3032        Scintec .mnd daily sodar file including all line endings. 
     33         
     34        Parse a known good .mnd file: 
     35         
     36        >>> main_data = MainData(good_mnd) 
    3137        """ 
    3238         
    3339        super(MainData, self).__init__() 
    34         self.blocks = [block.strip() 
    35                       for block in mnd.split('\n\n') 
    36                       if block.strip()] 
    37         self.format_header = [line.strip() 
    38                               for line in self.blocks[0].split('\n') 
    39                               if line.strip()] 
    40         self.file_header = [line.strip() 
    41                             for line in self.blocks[1].split('\n') 
    42                             if line.strip()] 
    43         self.profile_blocks = self.blocks[2:] 
     40        self._blocks = [self._block.strip() 
     41                      for self._block in mnd.split('\n\n') 
     42                      if self._block.strip()] 
     43        self._format_header = [self._line.strip() 
     44                              for self._line in self._blocks[0].split('\n') 
     45                              if self._line.strip()] 
     46        self._file_header = [self._line.strip() 
     47                            for self._line in self._blocks[1].split('\n') 
     48                            if self._line.strip()] 
     49        self._profile_blocks = self._blocks[2:] 
    4450                             
    45 def _testSetUp(mnd_dir,mnd_file): 
    46     module_dir = os.path.abspath(os.path.dirname(__file__)) 
    47     package_dir = os.path.split(module_dir)[0] 
    48     mnd_file = os.path.join(package_dir,'tests','data',mnd_dir,mnd_file) 
    49     mnd = open(mnd_file).read() 
    50     return mnd 
    51  
    5251def _test(): 
     52    """ 
     53    Run module tests in script mode. 
     54     
     55    >>> from sodar.scintec.maindata import _test 
     56    """ 
    5357    import doctest 
    54     doctest.testmod() 
     58    from sodar.tests import suite 
     59    good_mnd = suite.setUpGoodMndData() 
     60    doctest.testmod(extraglobs=dict(good_mnd=good_mnd)) 
    5561 
    5662if __name__ == "__main__":