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

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

Move the SVN client, and associated tests, to ndgCommon + tidy up
the help page content and other templates.

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