Changeset 290

Show
Ignore:
Timestamp:
09/15/06 17:08:08 (2 years ago)
Author:
thomase
Message:

Comprehensive checking of all attributes in GeographicEntityLite and GeographicNameLite (coordinates with svn commit [289]). All attributes on GeoEntityName? are populated and then queried via the standard mutator and accessor methods. Two GeographicNameLite children are added to the GeographicEntity, and their attributes are similarly excercised. The testbrowser is then invoked to inspect the urls, titles and contents of the entity and the first name. All attribute values are sought in the contents of the page, but no attempt is made to check their proper encapsulation and labeling.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • GeographicEntityLite/trunk/GeographicEntityLite/tests/ProgrammaticCreation.txt

    r270 r290  
    1 PublishGeoEntity.txt 
    2 ==================== 
    3  
    4 Test publishing of GeographicEntityLite objects. 
    5  
    6 A lot of this is cribbed from optilude's tutorial on plone.org. 
    7  
    8 Setup the test fixture 
     1=========================================================================== 
     2Copyright (C) 2006 Ancient World Mapping Center 
     3This program is free software; you can redistribute it and/or modify 
     4it under the terms of the GNU General Public License as published by 
     5the Free Software Foundation; either version 2 of the License, or 
     6(at your option) any later version. 
     7 
     8This program is distributed in the hope that it will be useful, 
     9but WITHOUT ANY WARRANTY; without even the implied warranty of 
     10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     11GNU General Public License for more details. 
     12 
     13You should have received a copy of the GNU General Public License along 
     14with this program; if not, write to the Free Software Foundation, Inc., 
     1551 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
     16 
     17About Pleiades 
     18-------------- 
     19 
     20Pleiades is an international research network and associated web portal and 
     21content management system devoted to the study of ancient geography.  
     22 
     23See http://icon.stoa.org/trac/pleiades/wiki. 
     24 
     25Funding for the creation of this software was provided by a grant from the  
     26U.S. National Endowment for the Humanities (http://www.neh.gov). 
     27=========================================================================== 
     28ProgrammaticCreation.txt 
     29=========================================================================== 
     30 
     31Test our ability to create and retrieve GeographicEntityLite objects and their 
     32subordinate GeographicNameLite objects 
     33 
     34optilude's tutorial on plone.org pointed the way to the sunlight 
     35 
     36Note that this test deliberately avoids dealing with unicode characters whose  
     37codepoints exceed 0xFF (255). 
     38 
     39Setup the test fixture and get a reference to a Plone folder therein 
    940 
    1041    >>> folder = self.folder 
    1142 
    12 Add one complete entity to the folder and check that it is complete 
    13  
    14     >>> enID = 'batlas-65-2-12
     43Add one complete entity to the folder and check all its attributes 
     44 
     45    >>> enID = 'tatlas-77pdq
    1546    >>> folder.invokeFactory('GeographicEntityLite', id=enID) 
    16     'batlas-65-2-12' 
    17      
     47    'tatlas-77pdq' 
     48     
     49Attempt to get a reference to the entity 
    1850    >>> en = getattr(folder, enID) 
    1951 
     52Set the title to the entity (Zope) title to match the ID until we know what the entity's names are 
    2053    >>> en.setTitle(enID) 
    2154    >>> en.Title() 
    22     'batlas-65-2-12' 
    23      
    24     >>> en.setDescription(u'An ancient settlement, attested from the Hellenistic to the Late Antique periods and located at modern Hisartepe, near Kızılca. It was known in antiquity by the name \'Amblada\'.') 
     55    'tatlas-77pdq' 
     56     
     57Set the standard description 
     58    >>> en.setDescription(u'A historic settlement, attested from the early 19th century and located at modern Ryland, near Huntsville. It was known in earlier times by the name(s): \'Ryland Mill\', \'Ryland Gin\'.') 
    2559    >>> en.Description() 
    26     "An ancient settlement, attested from the Hellenistic to the Late Antique periods and located at modern Hisartepe, near K\xc3\x84\xc2\xb1z\xc3\x84\xc2\xb1lca. It was known in antiquity by the name 'Amblada'." 
    27      
     60    "A historic settlement, attested from the early 19th century and located at modern Ryland, near Huntsville. It was known in earlier times by the name(s): 'Ryland Mill', 'Ryland Gin'." 
     61     
     62Set the project identifier. 
     63    >>> en.setIdentifier(enID) 
     64    >>> en.getIdentifier() 
     65    'tatlas-77pdq' 
     66 
     67Set the type of geographic entity 
    2868    >>> en.setGeoEntityType('settlement') 
    2969    >>> en.getGeoEntityType() 
    3070    'settlement' 
    3171     
    32     >>> en.setModernLocation(u'Hisartepe, near Kızılca') 
     72Set the modern location string 
     73    >>> en.setModernLocation(u'Ryland, near Huntsville') 
    3374    >>> en.getModernLocation() 
    34     'Hisartepe, near K\xc3\x84\xc2\xb1z\xc3\x84\xc2\xb1lca' 
    35      
    36     >>> en.setTimePeriods(['Hellenistic (Roman Republic)', 'Roman', 'Late Antique']) 
     75    'Ryland, near Huntsville' 
     76     
     77Historical periods for the entity 
     78    >>> en.setTimePeriods(['19th Century', '20th Century', '21st Century']) 
    3779    >>> en.getTimePeriods() 
    38     ('Hellenistic (Roman Republic)', 'Roman', 'Late Antique') 
    39      
    40     >>> en.setSecondaryReferences(['BAtlas 65 G2 Amblada', 'von Aulock 1977, 22-23', 'TIB Galatien 122']) 
     80    ('19th Century', '20th Century', '21st Century') 
     81     
     82References to secondary literature 
     83    >>> en.setSecondaryReferences(['TAtlas 65 Q2 Ryland', 'Elliott 2008, 22-23']) 
    4184    >>> en.getSecondaryReferences() 
    42     ('BAtlas 65 G2 Amblada', 'von Aulock 1977, 22-23', 'TIB Galatien 122') 
    43      
    44     >>> en.setSpatialCoordinates('37.5254199999999 31.7393100000008 0.0') 
     85    ('TAtlas 65 Q2 Ryland', 'Elliott 2008, 22-23') 
     86     
     87Set the spatial coordinates 
     88    >>> en.setSpatialCoordinates('34.769722222222 -86.4808333333333 0.0') 
    4589    >>> en.getSpatialCoordinates() 
    46     '37.5254199999999 31.7393100000008 0.0' 
    47      
     90    '34.769722222222 -86.4808333333333 0.0' 
     91     
     92Set the spatial coordinate type 
     93    >>> en.setSpatialGeometryType('point') 
     94    >>> en.getSpatialGeometryType() 
     95    'point' 
     96     
     97Enter the historical names and their constituent attributes 
     98 
    4899    >>> nameID = enID + '-n1' 
    49100    >>> en.invokeFactory('GeographicNameLite', id=nameID) 
    50     'batlas-65-2-12-n1' 
     101    'tatlas-77pdq-n1' 
    51102     
    52103    >>> en_name = getattr(en, nameID) 
    53104 
    54     >>> en_name.setTitle('Amblada') 
     105    >>> en_name.setTitle('Ryland Mill') 
    55106    >>> en_name.Title() 
    56     'Amblada
    57  
    58     >>> en_name.setIdentifier('batlas-65-2-12-n1'
     107    'Ryland Mill
     108 
     109    >>> en_name.setIdentifier(nameID
    59110    >>> en_name.getIdentifier() 
    60     'batlas-65-2-12-n1' 
    61      
    62     >>> en_name.setDescription(u'An attested name for an ancient settlement located at modern Hisartepe, near Kızılca.') 
     111    'tatlas-77pdq-n1' 
     112     
     113    >>> en_name.setGeoNameType('geographic') 
     114    >>> en_name.getGeoNameType() 
     115    'geographic' 
     116     
     117    >>> en_name.setDescription(u'An attested name for a historical settlement located at modern Ryland, near Huntsville.') 
    63118    >>> en_name.Description() 
    64     'An attested name for an ancient settlement located at modern Hisartepe, near K\xc3\x84\xc2\xb1z\xc3\x84\xc2\xb1lca.' 
    65      
    66     >>> en_name.setNameAttested(u'ጌΌβλαΎα') 
     119    'An attested name for a historical settlement located at modern Ryland, near Huntsville.' 
     120     
     121    >>> en_name.setNameAttested(u'Ryland Mill') 
    67122    >>> en_name.getNameAttested() 
    68     '\xc3\xa1\xc2\xbc\xc2\x8c\xc3\x8e\xc2\xbc\xc3\x8e\xc2\xb2\xc3\x8e\xc2\xbb\xc3\x8e\xc2\xb1\xc3\x8e\xc2\xb4\xc3\x8e\xc2\xb1' 
    69      
    70      
    71     >>> en_name.setNameLanguage('Ancient Greek') 
     123    'Ryland Mill' 
     124     
     125    >>> en_name.setNameLanguage('English') 
    72126    >>> en_name.getNameLanguage() 
    73     'Ancient Greek
    74  
    75     >>> en_name.setTimePeriods([]) 
     127    'English
     128 
     129    >>> en_name.setTimePeriods(['19th Century', '20th Century']) 
    76130    >>> en_name.getTimePeriods() 
    77     (
     131    ('19th Century', '20th Century'
    78132     
    79133    >>> en_name.setPrimaryReferences([]) 
     
    85139    () 
    86140     
     141    >>> nameID = enID + '-n2' 
     142    >>> en.invokeFactory('GeographicNameLite', id=nameID) 
     143    'tatlas-77pdq-n2' 
     144     
     145    >>> en_name = getattr(en, nameID) 
     146 
     147    >>> en_name.setTitle('Ryland Gin') 
     148    >>> en_name.Title() 
     149    'Ryland Gin' 
     150 
     151    >>> en_name.setIdentifier(nameID) 
     152    >>> en_name.getIdentifier() 
     153    'tatlas-77pdq-n2' 
     154     
     155    >>> en_name.setGeoNameType('geographic') 
     156    >>> en_name.getGeoNameType() 
     157    'geographic' 
     158     
     159    >>> en_name.setDescription(u'An attested name for a historical settlement located at modern Ryland, near Huntsville.') 
     160    >>> en_name.Description() 
     161    'An attested name for a historical settlement located at modern Ryland, near Huntsville.' 
     162     
     163    >>> en_name.setNameAttested(u'Ryland Gin') 
     164    >>> en_name.getNameAttested() 
     165    'Ryland Gin' 
     166     
     167    >>> en_name.setNameLanguage('English') 
     168    >>> en_name.getNameLanguage() 
     169    'English' 
     170 
     171    >>> en_name.setTimePeriods(['19th Century', '20th Century']) 
     172    >>> en_name.getTimePeriods() 
     173    ('19th Century', '20th Century') 
     174     
     175    >>> en_name.setPrimaryReferences([]) 
     176    >>> en_name.getPrimaryReferences() 
     177    () 
     178     
     179    >>> en_name.setSecondaryReferences([]) 
     180    >>> en_name.getSecondaryReferences() 
     181    () 
     182 
     183Re-set the entity title on the basis of the historical names 
    87184    >>> from Products.GeographicEntityLite.cooking import setGeoTitleFromNames 
    88185    >>> setGeoTitleFromNames(en)  
    89     'Amblada
     186    'Ryland Mill/Ryland Gin
    90187    >>> en.Title() 
    91     'Amblada
     188    'Ryland Mill/Ryland Gin
    92189     
    93190Initialize the test browser 
     
    113210    >>> browser.url == entity_url 
    114211    True 
    115     >>> browser.url.endswith('batlas-65-2-12') 
     212    >>> browser.url.endswith('tatlas-77pdq') 
    116213    True 
    117214     
    118215Check the html title 
    119216    >>> title = browser.title 
    120     >>> title.strip().startswith('Amblada\n') 
     217    >>> title.strip().startswith('Ryland Mill/Ryland Gin\n') 
    121218    True 
    122219     
     
    125222not yet. 
    126223    >>> browser.contents 
    127     '...batlas-65-2-12...' 
     224    '...tatlas-77pdq...' 
    128225    >>> browser.contents 
    129226    '...settlement...' 
    130227    >>> browser.contents 
    131     '...Hisartepe, near K\xc3\x84\xc2\xb1z\xc3\x84\xc2\xb1lca...' 
    132     >>> browser.contents 
    133     '...Hellenistic (Roman Republic)...' 
    134     >>> browser.contents 
    135     '...Roman...' 
    136     >>> browser.contents 
    137     '...Late Antique...' 
    138     >>> browser.contents 
    139     '...BAtlas 65 G2 Amblada...' 
    140     >>> browser.contents 
    141     '...von Aulock 1977, 22-23...' 
    142     >>> browser.contents 
    143     '...TIB Galatien 122...' 
    144     >>> browser.contents 
    145     '...37.5254199999999 31.7393100000008 0.0...' 
     228    '...Ryland, near Huntsville...' 
     229    >>> browser.contents 
     230    '...19th Century...' 
     231    >>> browser.contents 
     232    '...20th Century...' 
     233    >>> browser.contents 
     234    '...21st Century...' 
     235    >>> browser.contents 
     236    '...TAtlas 65 Q2 Ryland...' 
     237    >>> browser.contents 
     238    '...Elliott 2008, 22-23...' 
     239    >>> browser.contents 
     240    '...34.769722222222 -86.4808333333333 0.0...' 
    146241 
    147242Browse to the name 
    148     >>> link = browser.getLink('batlas-65-2-12-n1') 
     243    >>> link = browser.getLink('tatlas-77pdq-n1') 
    149244    >>> link.click() 
    150245     
    151246Check the url 
    152     >>> browser.url == entity_url + '/batlas-65-2-12-n1/' 
     247    >>> browser.url == entity_url + '/tatlas-77pdq-n1/' 
    153248    True 
    154249     
    155250Check the html title 
    156251    >>> title = browser.title 
    157     >>> title.strip().startswith('Amblada\n') 
     252    >>> title.strip().startswith('Ryland Mill\n') 
    158253    True     
    159254     
     
    162257not yet. 
    163258    >>> browser.contents 
    164     '...batlas-65-2-12-n1...' 
    165     >>> browser.contents 
    166     '...\xc3\xa1\xc2\xbc\xc2\x8c\xc3\x8e\xc2\xbc\xc3\x8e\xc2\xb2\xc3\x8e\xc2\xbb\xc3\x8e\xc2\xb1\xc3\x8e\xc2\xb4\xc3\x8e\xc2\xb1...' 
    167     >>> browser.contents 
    168     '...Amblada...' 
    169     >>> browser.contents 
    170     '...Ancient Greek...' 
    171      
     259    '...tatlas-77pdq-n1...' 
     260    >>> browser.contents 
     261    '...Ryland Mill...' 
     262    >>> browser.contents 
     263    '...geographic...' 
     264    >>> browser.contents 
     265    '...English...' 
     266    >>> browser.contents 
     267    '...19th Century...' 
     268    >>> browser.contents 
     269    '...20th Century...' 
     270