Changeset 298

Show
Ignore:
Timestamp:
09/18/06 16:32:28 (2 years ago)
Author:
thomase
Message:

Close ticket #96. batching.py now gracefully handles the absence of spatialCoordinates in input files. BatchCreation?.txt has dropped testing of individual input files, since there are separate doctest files for these, and has been modified to handle the larger number of test entities.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • GeographicEntityLite/trunk/GeographicEntityLite/Extensions/batching.py

    r277 r298  
    9898    en.setSecondaryReferences(ge.secondaryReferences) 
    9999     
    100     en.setDescription(ge.description) 
    101      
    102     coords = ge.spatialLocations[0][1].replace(',', ' ') 
    103     values = [v for v in coords.split()] 
    104     if len(values) == 2: 
    105         values.append('0.0') 
    106     en.setSpatialCoordinates(' '.join(values)) 
     100    en.setDescription(ge.description.encode('utf8')) 
     101     
     102    try: 
     103        coords = ge.spatialLocations[0][1].replace(',', ' ') 
     104    except: 
     105        pass 
     106    else: 
     107        values = [v for v in coords.split()] 
     108        if len(values) == 2: 
     109            values.append('0.0') 
     110        en.setSpatialCoordinates(' '.join(values)) 
    107111     
    108112    # add any names as children of the entity 
  • GeographicEntityLite/trunk/GeographicEntityLite/tests/BatchCreation.txt

    r277 r298  
    2121    u'x, y, and z' 
    2222     
    23 Load a single entity 
     23Test loading 
     24    >>> import glob 
    2425    >>> import os 
    2526    >>> source_dir = os.path.sep.join([os.environ['SOFTWARE_HOME'], 'Products', 'GeographicEntityLite', 'tests', 'data']) 
    2627    >>> from Products.GeographicEntityLite.Extensions.batching import load_entity 
    27     >>> source = "%s/batlas-65-2-24.xml" % (source_dir) 
    28     >>> load_entity(folder, source) 
     28    >>> source = "%s/batlas-65-2-24-grc.xml" % (source_dir) 
     29 
     30Load a whole batch of entities 
     31    >>> from Products.GeographicEntityLite.Extensions.batching import loaden 
     32    >>> loaden(folder, source_dir) 
     33    'Loaded 14 of 15 files. Failures:\nbatlas-99-9-99.xml\n' 
    2934 
    3035Check count of created entities 
    3136    >>> entities = folder.listFolderContents() 
    3237    >>> len(entities) 
    33     1 
    34  
    35 Get entity reference for further testing 
    36     >>> en = entities[0] 
    37      
    38 Verify the id is properly set 
    39     >>> en.getId() 
    40     'batlas-65-2-24' 
    41  
    42 Verify the title is properly set  
    43     >>> en.Title() 
    44     'Aphrodisias/Ninoe' 
    45  
    46 Verify the description is properly set 
    47     >>> en.Description() 
    48     'An ancient settlement, attested from the Classical through the Late Antique periods (modern location: Geyre). It was known in antiquity by the name(s): Aphrodisias and Ninoe.' 
    49      
    50 Verify the identifier field is properly set 
    51     >>> en.getIdentifier() 
    52     'batlas-65-2-24' 
    53      
    54 Verify the entity type is properly set 
    55     >>> en.getGeoEntityType() 
    56     'settlement' 
    57  
    58 Verify the modern location is properly set 
    59     >>> en.getModernLocation() 
    60     'Geyre' 
    61  
    62 Verify the time period(s) are properly set 
    63     >>> en.getTimePeriods() 
    64     ('Classical', 'Roman', 'Late Antique') 
    65  
    66 Verify the secondary reference(s) are properly set 
    67     >>> en.getSecondaryReferences() 
    68     ('BAtlas 65 A2 Aphrodisias/Ninoe', 'RE 2', 'NPauly 1', 'RE') 
    69  
    70 Verify the spatial coordinates are properly set 
    71     >>> en.getSpatialCoordinates() 
    72     '37.7144599999992 28.7288599999993 0.0' 
    73  
    74 Verify the spatial geometry type is properly set 
    75     >>> en.getSpatialGeometryType() 
    76     'point' 
    77      
    78 Check count of names 
    79     >>> names = en.listFolderContents() 
    80     >>> len(names) 
    81     2 
    82      
    83 Get reference to the first name for further testing 
    84     >>> nm0 = names[0] 
    85  
    86 Verify the id is properly set 
    87     >>> nm0.getId() 
    88     'batlas-65-2-24-n1' 
    89      
    90 Verify the title is properly set 
    91     >>> nm0.Title() 
    92     'Aphrodisias' 
    93      
    94 Verify the description is properly set 
    95     >>> nm0.Description() 
    96     'No description' 
    97      
    98 Verify the identifier is properly set 
    99     >>> nm0.getIdentifier() 
    100     'batlas-65-2-24-n1' 
    101      
    102 Verify the attested name is properly set 
    103     >>> nm0.getNameAttested() 
    104     '' 
    105  
    106 Verify the name language is properly set 
    107     >>> nm0.getNameLanguage() 
    108     '' 
    109  
    110 Verify the time period(s) for this name are properly set 
    111     >>> nm0.getTimePeriods() 
    112     ('Roman', 'Late Antique') 
    113      
    114 Verify the primary references for this name are properly set 
    115     >>> nm0.getPrimaryReferences() 
    116     () 
    117      
    118 Verify the secondary references for this name properly set 
    119     >>> nm0.getSecondaryReferences() 
    120     ('RE 2', 'NPauly 1') 
    121      
    122 Do the same things for the second name 
    123     >>> nm1 = names[1] 
    124  
    125     >>> nm1.getId() 
    126     'batlas-65-2-24-n2' 
    127      
    128     >>> nm1.Title() 
    129     'Ninoe' 
    130      
    131     >>> nm1.Description() 
    132     'No description' 
    133      
    134     >>> nm1.getIdentifier() 
    135     'batlas-65-2-24-n2' 
    136      
    137     >>> nm1.getNameAttested() 
    138     '' 
    139      
    140     >>> nm1.getNameLanguage() 
    141     '' 
    142  
    143     >>> nm1.getTimePeriods() 
    144     ('Classical',) 
    145      
    146     >>> nm1.getPrimaryReferences() 
    147     () 
    148      
    149     >>> nm1.getSecondaryReferences() 
    150     ('RE',) 
    151  
    152 Delete the entity and check for result 
    153     >>> folder.manage_delObjects(['batlas-65-2-24']) 
    154     >>> entities = folder.listFolderContents() 
    155     >>> len(entities) 
    156     0 
    157  
    158 Load a whole batch of entities 
    159     >>> from Products.GeographicEntityLite.Extensions.batching import loaden 
    160     >>> loaden(folder, source_dir) 
    161     'Loaded 7 of 8 files. Failures:\nbatlas-99-9-99.xml\n' 
    162  
    163 Check count of created entities 
    164     >>> entities = folder.listFolderContents() 
    165     >>> len(entities) 
    166     7 
     38    14 
    16739     
    16840Check ids of created entities 
    16941    >>> en_ids = [] 
    170     >>> en_ids.append(entities[0].getId()) 
    171     >>> en_ids.append(entities[1].getId()) 
    172     >>> en_ids.append(entities[2].getId()) 
    173     >>> en_ids.append(entities[3].getId()) 
    174     >>> en_ids.append(entities[4].getId()) 
    175     >>> en_ids.append(entities[5].getId()) 
    176     >>> en_ids.append(entities[6].getId()) 
     42    >>> for entity in entities: en_ids.append(entity.getId()) 
    17743    >>> 'batlas-65-2-3' in en_ids 
    17844    True 
     
    18955    >>> 'batlas-65-2-24' in en_ids 
    19056    True 
     57    >>> 'batlas-65-2-24-grc' in en_ids 
     58    True 
     59    >>> 'batlas-65-4-3' in en_ids 
     60    True 
     61    >>> 'batlas-65-4-9' in en_ids 
     62    True 
     63    >>> 'batlas-65-7-3' in en_ids 
     64    True 
     65    >>> 'batlas-65-7-56' in en_ids 
     66    True 
     67    >>> 'batlas-65-7-59' in en_ids 
     68    True 
     69    >>> 'batlas-65-8-3' in en_ids 
     70    True 
     71    >>> 'batlas-99-9-99' in en_ids 
     72    False 
    19173 
    192  
  • GeographicEntityLite/trunk/GeographicEntityLite/version.txt

    r289 r298  
    1 0.1 build 160 
     10.1 build 161