Ignore:
Timestamp:
15/12/08 09:38:08 (11 years ago)
Author:
cbyrom
Message:

Extend and update test suite for ndgUtils code - adding new package
to test lib code + new test data and improved test constants to
centralise test data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgutilstests/testconstants.py

    r4488 r4628  
    1313__revision__ = '$Id: $' 
    1414 
     15from ndgUtils.vocabtermdata import VocabTermData as VTD 
     16import ndgUtils.lib.existdbclient as dbc 
     17from ndgUtils.models.Atom import Atom 
     18 
     19DBCONFIG_FILE = "exist.config" 
     20 
     21TEST_GRANULITE = '..\\testdata\\example.granulite' 
     22GRANULITE_TITLE = 'this is a new test granulite' 
     23GRANULITE_TIME_AXIS = 'time0' 
     24GRANULITE_CDML_DATASETID = 'hadgem1_dataset' 
     25GRANULITE_PROVIDER_ID = 'badc.nerc.ac.uk' 
     26GRANULITE_DATASETID = 'calum_data_set' 
     27GRANULITE_LOGO = 'http:/blah/blah/a_logo_icon.png' 
     28GRANULITE_AUTHOR_NAME = 'calum byrom' 
     29GRANULITE_AUTHOR_URI = 'www.cb.org' 
     30GRANULITE_AUTHOR_ROLE = 'Data migrator' 
     31GRANULITE_T1 = '1996-4-19' 
     32GRANULITE_T2 = '1998-9-22' 
     33 
    1534VALID_REPOSITORY = "chinook.badc.rl.ac.uk" 
    1635VALID_PROVIDER_ID = 'badc.nerc.ac.uk' 
     
    2241VALID_DISCOVERY_PROVIDER_ID = "csl.gov.uk" 
    2342VALID_DISCOVERY_DOC_ID = "csl.gov.uk__1"         
     43 
     44validParams = ['OZONE MIXING RATIO (PPB ) | http://vocab.ndg.nerc.ac.uk/blah | OZONE', \ 
     45               'ERROR FLAG (OZONE MIXING RATIO ) | http://vocab.ndg.nerc.ac.uk/blah | ERROR', \ 
     46               'HYDROGEN PEROXIDE PPBV | http://vocab.ndg.nerc.ac.uk/blah | HYDROGEN', 
     47               'CADMIUM >1.21 M DIAMETER (PMOL M-3) INSTRUMENTAL DETECTION LIMIT 0.132 NM'] 
     48 
     49messyParams = ['OZONE MIXING RATIO &  (PPB     ) | http://vocab.ndg.nerc.ac.uk/blah | ozone', \ 
     50               'ERROR FLAG (OZONE MIXING > RATIO  ) | http://vocab.ndg.nerc.ac.uk/blah | error', \ 
     51               'Hydrogen Peroxide < ppbv | http://vocab.ndg.nerc.ac.uk/blah | hydrogen &'] 
     52 
     53summaryText = 'this is a summary of the granulite' 
     54 
     55csmlFile = '/db/moles_support/csml/csml_famous_control_month.xml' 
     56 
     57logo = '/blah/blah/a_logo_icon.png' 
     58 
     59title = 'this is a test granulite' 
     60 
     61datasetID = 'famous_control_month' 
     62 
     63id = 'tag:localhost:5000,2008-09-17:/view/badc.nerc.ac.uk__ATOM__' + datasetID 
     64 
     65atomName = 'http://localhost:5000/view/badc.nerc.ac.uk__ATOM__' + datasetID 
     66 
     67name = 'famous_control_month.atom' 
     68 
     69VTD = VTD() 
     70T1 = '2792-12-16' 
     71T2 = '2992-11-16' 
     72minX = '-90.0' 
     73minY = '-90.0' 
     74maxX = '360.0' 
     75maxY = '5505.29980469' 
     76 
     77xmlString = '<entry xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \ 
     78    'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \ 
     79    '<id>' + id + '</id>' + \ 
     80    '<title>' + title + '</title>' + \ 
     81        '<link href="' + atomName + '" rel="self"/>' + \ 
     82        '<link href="http://badc.nerc.ac.uk/a-real-wms-endpoint" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \ 
     83        '<link href="http://badc.nerc.ac.uk/alternate" rel="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" title="alternate page"/>' + \ 
     84        '<link href="' + logo + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD"/>' + \ 
     85        '<author><name>Tiddeman, David</name><uri>www.cb.org</uri></author>' + \ 
     86        '<contributor><name>Brian Bandy</name><uri>www.cb.org</uri></contributor>' + \ 
     87        '<moles:entity type="granule"><moles:molesISO><moles:responsibleParties>' + \ 
     88            '<moles:responsibleParty><name>calum byrom</name><uri>www.cb.org</uri><role>Metadata maintainer</role></moles:responsibleParty>' + \ 
     89            '<moles:responsibleParty><name>dom lowe</name><uri>www.badc.rl.ac.uk</uri><role>Metadata maintainer</role></moles:responsibleParty>' + \ 
     90            '</moles:responsibleParties><moles:datasetLanguage>English</moles:datasetLanguage>' + \ 
     91            '<moles:providerID>badc.nerc.ac.uk</moles:providerID>' + \ 
     92            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \ 
     93            '</moles:molesISO>' + \ 
     94        '</moles:entity>' + \ 
     95        '<category term="OZONE" scheme="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" label="OZONE MIXING RATIO (PPB )"/>' + \ 
     96        '<category term="ERROR" scheme="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" label="ERROR FLAG (OZONE MIXING RATIO )"/>' + \ 
     97        '<category term="HYDROGEN" scheme="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" label="HYDROGEN PEROXIDE PPBV"/>' + \ 
     98        '<category term="ATOM_TYPE" scheme="GRAN - NOT YET SET UP/None/GRANULE" label="GRANULE"></category>' + \ 
     99        '<summary>' + summaryText + '</summary>' + \ 
     100        '<content src="' + csmlFile + '" type="application/xml"/>' + \ 
     101        '<published>2008-06-17T10:15:19</published>' + \ 
     102        '<moles:temporalRange>' + T1 + '/' + T2 + '</moles:temporalRange>' + \ 
     103        '<georss:where><gml:Envelope><gml:lowerCorner>' + minX + ' ' + maxX + '</gml:lowerCorner><gml:upperCorner>' + minY + ' ' + maxY + '</gml:upperCorner></gml:Envelope></georss:where>' + \ 
     104    '</entry>' 
     105 
     106INVALID_TITLE = '\xa2' 
     107invalidXmlString = '<entry xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \ 
     108    'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \ 
     109    '<id>' + id + '</id>' + \ 
     110        '<link href="' + atomName + '" rel="self"/>' + \ 
     111        '<link href="http://badc.nerc.ac.uk/a-real-wms-endpoint" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \ 
     112        '<link href="http://badc.nerc.ac.uk/alternate" rel="alternate" title="alternate page"/>' + \ 
     113        '<link href="' + logo + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="' + VTD.LOGO_TERM + '"/>' + \ 
     114        '<contributor><name>Brian Bandy</name><uri>www.cb.org</uri></contributor>' + \ 
     115        '<moles:entity type="granule"><moles:molesISO><moles:responsibleParties>' + \ 
     116            '<moles:responsibleParty><name>calum byrom</name><uri>www.cb.org</uri><role>Metadata maintainer</role></moles:responsibleParty>' + \ 
     117            '<moles:responsibleParty><name>dom lowe</name><uri>www.badc.rl.ac.uk</uri><role>Metadata maintainer</role></moles:responsibleParty>' + \ 
     118            '</moles:responsibleParties><moles:datasetLanguage>English</moles:datasetLanguage>' + \ 
     119            '<moles:providerID>badc.nerc.ac.uk</moles:providerID>' + \ 
     120            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \ 
     121            '</moles:molesISO>' + \ 
     122        '</moles:entity>' + \ 
     123        '<category term="OZONE" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="OZONE MIXING RATIO (PPB )"/>' + \ 
     124        '<category term="ERROR" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="ERROR FLAG (OZONE MIXING RATIO )"/>' + \ 
     125        '<category term="HYDROGEN" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="HYDROGEN PEROXIDE PPBV"/>' + \ 
     126        '<category term="ATOM_TYPE" scheme="GRAN - NOT YET SET UP/None/GRANULE" label="GRANULE"></category>' + \ 
     127        '<summary>' + summaryText + '</summary>' + \ 
     128        '<content src="' + csmlFile + '" type="application/xml"/>' + \ 
     129        '<published>2008-06-17T10:15:19</published>' + \ 
     130        '<moles:temporalRange>' + T1 + '/' + T2 + '</moles:temporalRange>' + \ 
     131        '<georss:where><gml:Envelope><gml:lowerCorner>' + minX + ' ' + maxX + '</gml:lowerCorner><gml:upperCorner>' + minY + ' ' + maxY + '</gml:upperCorner></gml:Envelope></georss:where>' + \ 
     132    '</entry>' 
     133 
     134     
     135validAuthor = 'Tiddeman, David' 
     136validAuthors = [validAuthor + ' | www.cb.org', \ 
     137                    'Brian Bandy | www.cb.org'] 
     138     
     139validGranuleAuthors = ['calum byrom | www.cb.org | Metadata maintainer', \ 
     140                    'dom lowe | www.badc.rl.ac.uk | Metadata maintainer'] 
     141 
     142validLinks = ['http://badc.nerc.ac.uk/a-real-wms-endpoint | WMS | http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026',\ 
     143              'http://badc.nerc.ac.uk/alternate | alternate page | alternate', 
     144              '/blah/blah/a_logo_icon.png | logo | LOGO - NOT YET SET UP', 
     145              '/db/moles_support/granuleAtom/famous_control_month_granule.moles'] 
     146 
     147#t1 = '2792-12-16 0:0:0.0' 
     148#t2 = '2992-11-16 0:0:0.0' 
     149 
     150client = dbc.eXistDBClient(configFile = DBCONFIG_FILE, setUpDB = True) 
     151 
     152def createAtom(content): 
     153    atom = Atom(VTD.GRANULE_TERM) 
     154    atom.fromString(content) 
     155    return atom 
     156 
     157def createAtomInEXist(content): 
     158    atom = createAtom(content) 
     159    return client.createAtomInExist(atom) 
     160 
Note: See TracChangeset for help on using the changeset viewer.