source: ndgCommon/trunk/ndg/common/unittests/testconstants.py @ 5147

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/ndgCommon/trunk/ndg/common/unittests/testconstants.py@5147
Revision 5147, 12.0 KB checked in by cbyrom, 12 years ago (diff)

Add new tests and test constants.

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 ndg.common.src.models.vocabtermdata import VocabTermData as VTD
16from ndg.common.src.models.codetablerecord import CodeTableRecord
17import os, datetime
18
19def getTestDataDir(dir):
20    if os.path.exists(dir):
21        return dir
22
23    # avoid infinite recursions
24    if dir.count(parentDir) > 10:
25        raise SystemError("Could not find 'testdata' directory - with test config data\
26    - will not run tests until this has been set up correctly")
27   
28    return getTestDataDir(parentDir + dir)
29   
30# NB, directories depend on whether we're running on unix/windows or
31# whether we use nose to run the tests of python unit tests
32parentDir = '..' + os.sep
33TEST_DATA_DIR = getTestDataDir('testdata' + os.sep)
34
35TEST_COLLECTION_PATH = '/db/testcollection'
36TEST_FILE_NAME = 'testfile.xml'
37TEST_FILE_PATH = TEST_COLLECTION_PATH + '/' + TEST_FILE_NAME
38
39# this variable adjusts what eXist DB is used to run the tests against
40# - whilst the tests do clean up after themselves, it's probably best not to
41# run tests using a production environment DB!
42EXIST_DB = 'bora.badc.rl.ac.uk'
43#EXIST_DB = 'chinook.badc.rl.ac.uk'
44#EXIST_DB = 'localhost'
45PG_DBCONFIG_FILE = TEST_DATA_DIR + 'pg.config'
46EXIST_DBCONFIG_FILE = TEST_DATA_DIR + 'exist.config'
47INVALID_TEST_GRANULITE = TEST_DATA_DIR + 'example.granulite'
48VALID_TEST_GRANULITE = TEST_DATA_DIR + 'valid_example.granulite'
49MOLES_FILE_NAME = TEST_DATA_DIR + 'dataent_TESTDATA.xml'
50VALID_MOLES_ID = 'dataent_TESTDATA'
51VALID_PROVIDER_ID = 'badc.nerc.ac.uk'
52VALID_NDG_URL = VALID_PROVIDER_ID + '__NDG-B1__' + VALID_MOLES_ID
53
54NDG_CONFIG_FILE = TEST_DATA_DIR + 'ndgDiscovery.config'
55DIF_FILE = TEST_DATA_DIR + 'dataent_NDSC_DIF.xml'
56
57GRANULITE_TITLE = 'this is a new test granulite'
58GRANULITE_TIME_AXIS = 'time0'
59GRANULITE_CDML_DATASETID = 'test_hadgem1_dataset'
60GRANULITE_PROVIDER_ID = 'badc.nerc.ac.uk'
61GRANULITE_PROVIDER_ID2 = 'neodc.nerc.ac.uk'
62GRANULITE_DATASETID = 'calum_data_set'
63GRANULITE_LOGO = 'http://www.tessella.com/wp-content/themes/tessella/images/Tessella_Logo.png'
64GRANULITE_AUTHOR_NAME = 'calum byrom'
65GRANULITE_AUTHOR_URI = 'www.cb.org'
66GRANULITE_AUTHOR_ROLE = 'Data migrator'
67GRANULITE_T1 = '1996-4-19'
68GRANULITE_T2 = '1998-9-22'
69
70INVALID_XQUERY = "for $DE in collection('blah') return $DE"
71
72INVALID_NDG_URL = 'badc.nerc.ac.uk__NDG-B1__dataent_hadisstBLAHH'
73VALID_DISCOVERY_URL = '/view/' + VALID_NDG_URL
74VALID_RETRIEVE_URL = '/retrieve/' + VALID_NDG_URL
75INVALID_URL = 'http://invalid.blah.com'
76VALID_URL = 'http://www.google.co.uk'
77VALID_DISCOVERY_URL2 = '/view/badc.nerc.ac.uk__ATOM__famous_control_month_test_file'
78
79VALID_REPOSITORY = "chinook.badc.rl.ac.uk"
80VALID_MOLES_DOC_ID = 'dataent_hadisst'
81VALID_NDGA_DOC_ID = 'COAPEC_500YrRun_wholerun_annual_atmos'
82VALID_NUMSIM_DOC_ID = 'HadGEM1_CodeBase'
83VALID_ATOM_DOC_ID = 'dataent_11679938403412067'
84
85VALID_DISCOVERY_PROVIDER_ID = "csl.gov.uk"
86VALID_DISCOVERY_DOC_ID = "csl.gov.uk__1"       
87
88validParams = ['OZONE MIXING RATIO (PPB ) | http://vocab.ndg.nerc.ac.uk/blah | OZONE', \
89               'ERROR FLAG (OZONE MIXING RATIO ) | http://vocab.ndg.nerc.ac.uk/blah | ERROR', \
90               'HYDROGEN PEROXIDE PPBV | http://vocab.ndg.nerc.ac.uk/blah | HYDROGEN',
91               'CADMIUM >1.21 M DIAMETER (PMOL M-3) INSTRUMENTAL DETECTION LIMIT 0.132 NM']
92
93messyParams = ['OZONE MIXING RATIO &  (PPB     ) | http://vocab.ndg.nerc.ac.uk/blah | ozone', \
94               'ERROR FLAG (OZONE MIXING > RATIO  ) | http://vocab.ndg.nerc.ac.uk/blah | error', \
95               'Hydrogen Peroxide < ppbv | http://vocab.ndg.nerc.ac.uk/blah | hydrogen &']
96
97summaryText = 'this is a summary of the granulite'
98
99csmlFile = '/db/moles_support/csml/csml_famous_control_month.xml'
100
101logoURL = 'http://www.tessella.com/wp-content/themes/tessella/images/Tessella_Logo.png'
102
103title = 'this is a test atom for use with the test suite'
104
105datasetID = 'famous_control_month_test_file'
106datasetID2 = 'infamous_control_year_test_hedgehog'
107
108ndgURI = VALID_PROVIDER_ID + '__ATOM__' + datasetID
109
110id = 'tag:localhost:5000,2008-09-17:/view/' + ndgURI
111
112atomName = 'http://localhost:5000/view/' + ndgURI
113
114name = datasetID + '.atom'
115
116VTD = VTD()
117T1 = '2792-12-16'
118T2 = '2992-11-16'
119minX = '-90.0'
120minY = '-90.0'
121maxX = '360.0'
122maxY = '5505.29980469'
123ABBREVIATION = 'BLAH'
124VALID_EMAIL = 'dt@bob.org'
125INVALID_EMAIL = 'dt.bob.org'
126INVALID_FILE = 'blah.txt'
127INVALID_COLLECTION = '/db/gooseberry'
128createdDate = datetime.datetime.today().strftime("%Y-%m-%dT%H_%M_%S")
129
130MOLES_ENTITY_STRING = '<moles:entity type="granule"><moles:molesISO><moles:responsibleParties>' + \
131            '<moles:responsibleParty><moles:name>calum byrom</moles:name><moles:uri>www.cb.org</moles:uri><moles:role>Metadata maintainer</moles:role></moles:responsibleParty>' + \
132            '<moles:responsibleParty><moles:name>dom lowe</moles:name><moles:uri>www.badc.rl.ac.uk</moles:uri><moles:role>Metadata maintainer</moles:role></moles:responsibleParty>' + \
133            '</moles:responsibleParties><moles:datasetLanguage>English</moles:datasetLanguage>' + \
134            '<moles:datasetLanguage>English</moles:datasetLanguage>' + \
135            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \
136            '<moles:abbreviation>' + ABBREVIATION + '</moles:abbreviation>' + \
137            '<moles:providerID>' + VALID_PROVIDER_ID + '</moles:providerID>' + \
138            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \
139            '<moles:created>' + createdDate + '</moles:created>' + \
140            '</moles:molesISO>' + \
141        '</moles:entity>'
142       
143linkHref1 = 'http://www.tessella.com/'
144linkHref2 = 'http://www.tessella.com'
145
146xmlString = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \
147    'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \
148    '<id>' + id + '</id>' + \
149    '<title>' + title + '</title>' + \
150        '<link href="' + atomName + '" rel="self"/>' + \
151        '<link href="' + linkHref1 + '" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \
152        '<link href="' + linkHref2 + '" rel="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02" title="alternate page"/>' + \
153        '<link href="' + logoURL + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02"/>' + \
154        '<author><name>Tiddeman, David</name><email>' + VALID_EMAIL + '</email></author>' + \
155        '<contributor><name>Brian Bandy</name><email>bb@bb.org</email></contributor>' + \
156        MOLES_ENTITY_STRING + \
157        '<category term="OZONE" scheme="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02" label="OZONE MIXING RATIO (PPB )"/>' + \
158        '<category term="ERROR" scheme="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02" label="ERROR FLAG (OZONE MIXING RATIO )"/>' + \
159        '<category term="HYDROGEN" scheme="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02" label="HYDROGEN PEROXIDE PPBV"/>' + \
160        '<category term="ATOM_TYPE" scheme="GRAN - NOT YET SET UP/None/GRANULE" label="GRANULE"></category>' + \
161        '<summary>' + summaryText + '</summary>' + \
162        '<content src="' + csmlFile + '" type="application/xml"/>' + \
163        '<published>2008-06-17T10:15:19</published>' + \
164        '<moles:temporalRange>' + T1 + '/' + T2 + '</moles:temporalRange>' + \
165        '<georss:where><gml:Envelope><gml:lowerCorner>' + minX + ' ' + minY + '</gml:lowerCorner><gml:upperCorner>' + maxX + ' ' + maxY + '</gml:upperCorner></gml:Envelope></georss:where>' + \
166    '</entry>'
167
168invalidEmailXmlString = xmlString.replace(VALID_EMAIL, INVALID_EMAIL)
169
170INVALID_TITLE = '\xa2'
171invalidXmlString = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \
172    'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \
173    '<id>' + id + '</id>' + \
174        '<link href="' + atomName + '" rel="self"/>' + \
175        '<link href="http://badc.nerc.ac.uk/a-real-wms-endpoint" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \
176        '<link href="http://badc.nerc.ac.uk/alternate" rel="alternate" title="alternate page"/>' + \
177        '<link href="' + logoURL + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="' + VTD.LOGO_TERM + '"/>' + \
178        '<contributor><name>Brian Bandy</name><uri>www.cb.org</uri></contributor>' + \
179        '<moles:entity type="granule"><moles:molesISO><moles:responsibleParties>' + \
180            '<moles:responsibleParty><moles:name>calum byrom</moles:name><moles:uri>www.cb.org</moles:uri><moles:role>Metadata maintainer</moles:role></moles:responsibleParty>' + \
181            '<moles:responsibleParty><moles:name>dom lowe</moles:name><moles:uri>www.badc.rl.ac.uk</moles:uri><moles:role>Metadata maintainer</moles:role></moles:responsibleParty>' + \
182            '</moles:responsibleParties><moles:datasetLanguage>English</moles:datasetLanguage>' + \
183            '<moles:providerID>badc.nerc.ac.uk</moles:providerID>' + \
184            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \
185            '</moles:molesISO>' + \
186        '</moles:entity>' + \
187        '<category term="OZONE" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="OZONE MIXING RATIO (PPB )"/>' + \
188        '<category term="ERROR" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="ERROR FLAG (OZONE MIXING RATIO )"/>' + \
189        '<category term="HYDROGEN" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="HYDROGEN PEROXIDE PPBV"/>' + \
190        '<category term="ATOM_TYPE" scheme="GRAN - NOT YET SET UP/None/GRANULE" label="GRANULE"></category>' + \
191        '<summary>' + summaryText + '</summary>' + \
192        '<content src="' + csmlFile + '" type="application/xml"/>' + \
193        '<published>2008-06-17T10:15:19</published>' + \
194        '<moles:temporalRange>' + T1 + '/' + T2 + '</moles:temporalRange>' + \
195        '<georss:where><gml:Envelope><gml:lowerCorner>' + minX + ' ' + maxX + '</gml:lowerCorner><gml:upperCorner>' + minY + ' ' + maxY + '</gml:upperCorner></gml:Envelope></georss:where>' + \
196    '</entry>'
197
198   
199validAuthor = 'Tiddeman, David'
200validAuthors = [validAuthor + ' | www.cb.org', \
201                    'Brian Bandy | www.cb.org']
202   
203validGranuleAuthors = ['calum byrom | www.cb.org | Metadata maintainer', \
204                    'dom lowe | www.badc.rl.ac.uk | Metadata maintainer']
205
206validLinks = [linkHref1 + ' | WMS | http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026',\
207              linkHref2 + ' | alternate page | http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02',
208              logoURL + ' | logo | LOGO - NOT YET SET UP',
209              '/db/moles_support/granuleAtom/famous_control_month_granule.moles']
210
211
212STANDARD_NAMES_LIST = "http://vocab.ndg.nerc.ac.uk/list/P071/11"
213STANDARD_NAME_TERM = "http://vocab.ndg.nerc.ac.uk/term/P071/11/CFSN0012"
214VALID_SEARCH_TEXT = "temperature"
215VALID_SEARCH_TERM = "*%s*" %VALID_SEARCH_TEXT
216INVALID_SEARCH_TERM = "space_monkeys"
217SN_TERM_NAME = "aerosol_angstrom_exponent"
218SN_ABBREV = ""
219SN_DEF = "'Aerosol' means the suspended liquid or solid particles in air (except cloud droplets)."
220SN_DEF_2 = "blah"
221SN_MOD_DATE = "2006-09-26T17:12:43.000+00:00"
222SN_LIST_MOD_DATE = "2008-11-11T16:08:00.000+00:00"
223SN_LIST_DEF = "Terms used for definitive but not necessarily comprehensive descriptions of measured phenomena in the CF conventions (a content standard for data stored in NetCDF)."
224SN_LIST_VERSION = "11"
225SN_LIST_LONG_NAME = "Climate and Forecast Standard Names"
226SN_LIST_SHORT_NAME = "CF Standard Names"
227SN_LIST_MAIL_GROUP = "test@test.com"
228
229CODE_TABLE_RECORD_1 = CodeTableRecord()
230CODE_TABLE_RECORD_1.setData(STANDARD_NAMES_LIST, SN_TERM_NAME, SN_TERM_NAME, 
231                            SN_ABBREV, SN_DEF, SN_MOD_DATE)
232CODE_TABLE_RECORD_2 = CodeTableRecord()
233CODE_TABLE_RECORD_2.setData(STANDARD_NAMES_LIST, SN_TERM_NAME, SN_TERM_NAME, 
234                            SN_ABBREV, SN_DEF_2, SN_MOD_DATE)
Note: See TracBrowser for help on using the repository browser.