Changeset 290
- Timestamp:
- 09/15/06 17:08:08 (2 years ago)
- 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 =========================================================================== 2 Copyright (C) 2006 Ancient World Mapping Center 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License as published by 5 the Free Software Foundation; either version 2 of the License, or 6 (at your option) any later version. 7 8 This program is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along 14 with this program; if not, write to the Free Software Foundation, Inc., 15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 17 About Pleiades 18 -------------- 19 20 Pleiades is an international research network and associated web portal and 21 content management system devoted to the study of ancient geography. 22 23 See http://icon.stoa.org/trac/pleiades/wiki. 24 25 Funding for the creation of this software was provided by a grant from the 26 U.S. National Endowment for the Humanities (http://www.neh.gov). 27 =========================================================================== 28 ProgrammaticCreation.txt 29 =========================================================================== 30 31 Test our ability to create and retrieve GeographicEntityLite objects and their 32 subordinate GeographicNameLite objects 33 34 optilude's tutorial on plone.org pointed the way to the sunlight 35 36 Note that this test deliberately avoids dealing with unicode characters whose 37 codepoints exceed 0xFF (255). 38 39 Setup the test fixture and get a reference to a Plone folder therein 9 40 10 41 >>> folder = self.folder 11 42 12 Add one complete entity to the folder and check that it is complete13 14 >>> enID = ' batlas-65-2-12'43 Add one complete entity to the folder and check all its attributes 44 45 >>> enID = 'tatlas-77pdq' 15 46 >>> folder.invokeFactory('GeographicEntityLite', id=enID) 16 'batlas-65-2-12' 17 47 'tatlas-77pdq' 48 49 Attempt to get a reference to the entity 18 50 >>> en = getattr(folder, enID) 19 51 52 Set the title to the entity (Zope) title to match the ID until we know what the entity's names are 20 53 >>> en.setTitle(enID) 21 54 >>> 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 57 Set 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\'.') 25 59 >>> 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 62 Set the project identifier. 63 >>> en.setIdentifier(enID) 64 >>> en.getIdentifier() 65 'tatlas-77pdq' 66 67 Set the type of geographic entity 28 68 >>> en.setGeoEntityType('settlement') 29 69 >>> en.getGeoEntityType() 30 70 'settlement' 31 71 32 >>> en.setModernLocation(u'Hisartepe, near Kızılca') 72 Set the modern location string 73 >>> en.setModernLocation(u'Ryland, near Huntsville') 33 74 >>> 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 77 Historical periods for the entity 78 >>> en.setTimePeriods(['19th Century', '20th Century', '21st Century']) 37 79 >>> 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 82 References to secondary literature 83 >>> en.setSecondaryReferences(['TAtlas 65 Q2 Ryland', 'Elliott 2008, 22-23']) 41 84 >>> 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 87 Set the spatial coordinates 88 >>> en.setSpatialCoordinates('34.769722222222 -86.4808333333333 0.0') 45 89 >>> en.getSpatialCoordinates() 46 '37.5254199999999 31.7393100000008 0.0' 47 90 '34.769722222222 -86.4808333333333 0.0' 91 92 Set the spatial coordinate type 93 >>> en.setSpatialGeometryType('point') 94 >>> en.getSpatialGeometryType() 95 'point' 96 97 Enter the historical names and their constituent attributes 98 48 99 >>> nameID = enID + '-n1' 49 100 >>> en.invokeFactory('GeographicNameLite', id=nameID) 50 ' batlas-65-2-12-n1'101 'tatlas-77pdq-n1' 51 102 52 103 >>> en_name = getattr(en, nameID) 53 104 54 >>> en_name.setTitle(' Amblada')105 >>> en_name.setTitle('Ryland Mill') 55 106 >>> en_name.Title() 56 ' Amblada'57 58 >>> en_name.setIdentifier( 'batlas-65-2-12-n1')107 'Ryland Mill' 108 109 >>> en_name.setIdentifier(nameID) 59 110 >>> 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.') 63 118 >>> en_name.Description() 64 'An attested name for a n 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') 67 122 >>> 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') 72 126 >>> en_name.getNameLanguage() 73 ' Ancient Greek'74 75 >>> en_name.setTimePeriods([ ])127 'English' 128 129 >>> en_name.setTimePeriods(['19th Century', '20th Century']) 76 130 >>> en_name.getTimePeriods() 77 ( )131 ('19th Century', '20th Century') 78 132 79 133 >>> en_name.setPrimaryReferences([]) … … 85 139 () 86 140 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 183 Re-set the entity title on the basis of the historical names 87 184 >>> from Products.GeographicEntityLite.cooking import setGeoTitleFromNames 88 185 >>> setGeoTitleFromNames(en) 89 ' Amblada'186 'Ryland Mill/Ryland Gin' 90 187 >>> en.Title() 91 ' Amblada'188 'Ryland Mill/Ryland Gin' 92 189 93 190 Initialize the test browser … … 113 210 >>> browser.url == entity_url 114 211 True 115 >>> browser.url.endswith(' batlas-65-2-12')212 >>> browser.url.endswith('tatlas-77pdq') 116 213 True 117 214 118 215 Check the html title 119 216 >>> title = browser.title 120 >>> title.strip().startswith(' Amblada\n')217 >>> title.strip().startswith('Ryland Mill/Ryland Gin\n') 121 218 True 122 219 … … 125 222 not yet. 126 223 >>> browser.contents 127 '... batlas-65-2-12...'224 '...tatlas-77pdq...' 128 225 >>> browser.contents 129 226 '...settlement...' 130 227 >>> 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...' 146 241 147 242 Browse to the name 148 >>> link = browser.getLink(' batlas-65-2-12-n1')243 >>> link = browser.getLink('tatlas-77pdq-n1') 149 244 >>> link.click() 150 245 151 246 Check the url 152 >>> browser.url == entity_url + '/ batlas-65-2-12-n1/'247 >>> browser.url == entity_url + '/tatlas-77pdq-n1/' 153 248 True 154 249 155 250 Check the html title 156 251 >>> title = browser.title 157 >>> title.strip().startswith(' Amblada\n')252 >>> title.strip().startswith('Ryland Mill\n') 158 253 True 159 254 … … 162 257 not yet. 163 258 >>> 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
