source: exist/trunk/python/ndgutilstests/testconstants.py @ 4641

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/python/ndgutilstests/testconstants.py@4641
Revision 4641, 8.2 KB checked in by cbyrom, 12 years ago (diff)

Improve test suite, allowing referenced artefacts to be properly set
up and removed before and after tests + set global logging + adjust
file references + add required data files + simplify and fix some tests.

Line 
1"""
2Constants to use in the various test cases
3
4NERC Data Grid Project
5"""
6__author__ = "C Byrom - Tessella"
7__date__ = "03/09/08"
8__copyright__ = "(C) 2008 STFC & NERC"
9__license__ = \
10"""This software may be distributed under the terms of the Q Public
11License, version 1.0 or later."""
12__contact__ = "b.n.lawrence@rl.ac.uk"
13__revision__ = '$Id: $'
14
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
34VALID_REPOSITORY = "chinook.badc.rl.ac.uk"
35VALID_PROVIDER_ID = 'badc.nerc.ac.uk'
36VALID_MOLES_DOC_ID = 'dataent_hadisst'
37VALID_NDGA_DOC_ID = 'COAPEC_500YrRun_wholerun_annual_atmos'
38VALID_NUMSIM_DOC_ID = 'HadGEM1_CodeBase'
39VALID_ATOM_DOC_ID = 'dataent_11679938403412067'
40
41VALID_DISCOVERY_PROVIDER_ID = "csl.gov.uk"
42VALID_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_test_file'
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 = datasetID + '.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/Logo"/>' + \
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 + ' ' + minY + '</gml:lowerCorner><gml:upperCorner>' + maxX + ' ' + 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 TracBrowser for help on using the repository browser.