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

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

Fix issues with the granlite 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 ndg.common.src.models.vocabtermdata import VocabTermData as VTD
16import os, datetime
17
18BASE_DIR = 'unittests'
19
20def getTestDataDir(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
33parentDir = '..' + os.sep
34TEST_DATA_DIR = getTestDataDir('testdata' + os.sep)
35
36
37TEST_COLLECTION_PATH = '/db/testcollection'
38TEST_FILE_NAME = 'testfile.xml'
39TEST_FILE_PATH = TEST_COLLECTION_PATH + '/' + TEST_FILE_NAME
40
41EXIST_DB = 'chinook.badc.rl.ac.uk'
42#EXIST_DB = 'localhost'
43PG_DBCONFIG_FILE = TEST_DATA_DIR + 'pg.config'
44EXIST_DBCONFIG_FILE = TEST_DATA_DIR + 'exist.config'
45INVALID_TEST_GRANULITE = TEST_DATA_DIR + 'example.granulite'
46VALID_TEST_GRANULITE = TEST_DATA_DIR + 'valid_example.granulite'
47MOLES_FILE_NAME = TEST_DATA_DIR + 'dataent_TESTDATA.xml'
48VALID_MOLES_ID = 'dataent_TESTDATA'
49VALID_PROVIDER_ID = 'badc.nerc.ac.uk'
50VALID_NDG_URL = VALID_PROVIDER_ID + '__NDG-B1__' + VALID_MOLES_ID
51
52NDG_CONFIG_FILE = TEST_DATA_DIR + 'ndgDiscovery.config'
53DIF_FILE = TEST_DATA_DIR + 'dataent_NDSC_DIF.xml'
54
55GRANULITE_TITLE = 'this is a new test granulite'
56GRANULITE_TIME_AXIS = 'time0'
57GRANULITE_CDML_DATASETID = 'test_hadgem1_dataset'
58GRANULITE_PROVIDER_ID = 'badc.nerc.ac.uk'
59GRANULITE_PROVIDER_ID2 = 'neodc.nerc.ac.uk'
60GRANULITE_DATASETID = 'calum_data_set'
61GRANULITE_LOGO = 'http://www.tessella.com/wp-content/themes/tessella/images/Tessella_Logo.png'
62GRANULITE_AUTHOR_NAME = 'calum byrom'
63GRANULITE_AUTHOR_URI = 'www.cb.org'
64GRANULITE_AUTHOR_ROLE = 'Data migrator'
65GRANULITE_T1 = '1996-4-19'
66GRANULITE_T2 = '1998-9-22'
67
68INVALID_XQUERY = "for $DE in collection('blah') return $DE"
69
70INVALID_NDG_URL = 'badc.nerc.ac.uk__NDG-B1__dataent_hadisstBLAHH'
71VALID_DISCOVERY_URL = 'http://ndgbeta.badc.rl.ac.uk/view/' + VALID_NDG_URL
72VALID_RETRIEVE_URL = 'http://ndgbeta.badc.rl.ac.uk/retrieve/' + VALID_NDG_URL
73INVALID_URL = 'http://invalid.blah.com'
74VALID_URL = 'http://www.google.co.uk'
75VALID_DISCOVERY_URL2 = 'http://ndgbeta.badc.rl.ac.uk/view/badc.nerc.ac.uk__ATOM__famous_control_month_test_file'
76
77VALID_REPOSITORY = "chinook.badc.rl.ac.uk"
78VALID_MOLES_DOC_ID = 'dataent_hadisst'
79VALID_NDGA_DOC_ID = 'COAPEC_500YrRun_wholerun_annual_atmos'
80VALID_NUMSIM_DOC_ID = 'HadGEM1_CodeBase'
81VALID_ATOM_DOC_ID = 'dataent_11679938403412067'
82
83VALID_DISCOVERY_PROVIDER_ID = "csl.gov.uk"
84VALID_DISCOVERY_DOC_ID = "csl.gov.uk__1"       
85
86validParams = ['OZONE MIXING RATIO (PPB ) | http://vocab.ndg.nerc.ac.uk/blah | OZONE', \
87               'ERROR FLAG (OZONE MIXING RATIO ) | http://vocab.ndg.nerc.ac.uk/blah | ERROR', \
88               'HYDROGEN PEROXIDE PPBV | http://vocab.ndg.nerc.ac.uk/blah | HYDROGEN',
89               'CADMIUM >1.21 M DIAMETER (PMOL M-3) INSTRUMENTAL DETECTION LIMIT 0.132 NM']
90
91messyParams = ['OZONE MIXING RATIO &  (PPB     ) | http://vocab.ndg.nerc.ac.uk/blah | ozone', \
92               'ERROR FLAG (OZONE MIXING > RATIO  ) | http://vocab.ndg.nerc.ac.uk/blah | error', \
93               'Hydrogen Peroxide < ppbv | http://vocab.ndg.nerc.ac.uk/blah | hydrogen &']
94
95summaryText = 'this is a summary of the granulite'
96
97csmlFile = '/db/moles_support/csml/csml_famous_control_month.xml'
98
99logoURL = 'http://www.tessella.com/wp-content/themes/tessella/images/Tessella_Logo.png'
100
101title = 'this is a test granulite'
102
103datasetID = 'famous_control_month_test_file'
104datasetID2 = 'infamous_control_year_test_hedgehog'
105
106ndgURI = VALID_PROVIDER_ID + '__ATOM__' + datasetID
107
108id = 'tag:localhost:5000,2008-09-17:/view/' + ndgURI
109
110atomName = 'http://localhost:5000/view/' + ndgURI
111
112name = datasetID + '.atom'
113
114VTD = VTD()
115T1 = '2792-12-16'
116T2 = '2992-11-16'
117minX = '-90.0'
118minY = '-90.0'
119maxX = '360.0'
120maxY = '5505.29980469'
121ABBREVIATION = 'BLAH'
122VALID_EMAIL = 'dt@bob.org'
123INVALID_EMAIL = 'dt.bob.org'
124INVALID_FILE = 'blah.txt'
125INVALID_COLLECTION = '/db/gooseberry'
126createdDate = datetime.datetime.today().strftime("%Y-%m-%dT%H_%M_%S")
127
128MOLES_ENTITY_STRING = '<moles:entity type="granule"><moles:molesISO><moles:responsibleParties>' + \
129            '<moles:responsibleParty><moles:name>calum byrom</moles:name><moles:uri>www.cb.org</moles:uri><moles:role>Metadata maintainer</moles:role></moles:responsibleParty>' + \
130            '<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>' + \
131            '</moles:responsibleParties><moles:datasetLanguage>English</moles:datasetLanguage>' + \
132            '<moles:datasetLanguage>English</moles:datasetLanguage>' + \
133            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \
134            '<moles:abbreviation>' + ABBREVIATION + '</moles:abbreviation>' + \
135            '<moles:providerID>' + VALID_PROVIDER_ID + '</moles:providerID>' + \
136            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \
137            '<moles:created>' + createdDate + '</moles:created>' + \
138            '</moles:molesISO>' + \
139        '</moles:entity>'
140       
141linkHref1 = 'http://www.tessella.com/'
142linkHref2 = 'http://www.tessella.com'
143
144xmlString = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \
145    'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \
146    '<id>' + id + '</id>' + \
147    '<title>' + title + '</title>' + \
148        '<link href="' + atomName + '" rel="self"/>' + \
149        '<link href="' + linkHref1 + '" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \
150        '<link href="' + linkHref2 + '" rel="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02" title="alternate page"/>' + \
151        '<link href="' + logoURL + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02"/>' + \
152        '<author><name>Tiddeman, David</name><email>' + VALID_EMAIL + '</email></author>' + \
153        '<contributor><name>Brian Bandy</name><email>bb@bb.org</email></contributor>' + \
154        MOLES_ENTITY_STRING + \
155        '<category term="OZONE" scheme="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02" label="OZONE MIXING RATIO (PPB )"/>' + \
156        '<category term="ERROR" scheme="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02" label="ERROR FLAG (OZONE MIXING RATIO )"/>' + \
157        '<category term="HYDROGEN" scheme="http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02" label="HYDROGEN PEROXIDE PPBV"/>' + \
158        '<category term="ATOM_TYPE" scheme="GRAN - NOT YET SET UP/None/GRANULE" label="GRANULE"></category>' + \
159        '<summary>' + summaryText + '</summary>' + \
160        '<content src="' + csmlFile + '" type="application/xml"/>' + \
161        '<published>2008-06-17T10:15:19</published>' + \
162        '<moles:temporalRange>' + T1 + '/' + T2 + '</moles:temporalRange>' + \
163        '<georss:where><gml:Envelope><gml:lowerCorner>' + minX + ' ' + minY + '</gml:lowerCorner><gml:upperCorner>' + maxX + ' ' + maxY + '</gml:upperCorner></gml:Envelope></georss:where>' + \
164    '</entry>'
165
166invalidEmailXmlString = xmlString.replace(VALID_EMAIL, INVALID_EMAIL)
167
168INVALID_TITLE = '\xa2'
169invalidXmlString = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \
170    'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \
171    '<id>' + id + '</id>' + \
172        '<link href="' + atomName + '" rel="self"/>' + \
173        '<link href="http://badc.nerc.ac.uk/a-real-wms-endpoint" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \
174        '<link href="http://badc.nerc.ac.uk/alternate" rel="alternate" title="alternate page"/>' + \
175        '<link href="' + logoURL + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="' + VTD.LOGO_TERM + '"/>' + \
176        '<contributor><name>Brian Bandy</name><uri>www.cb.org</uri></contributor>' + \
177        '<moles:entity type="granule"><moles:molesISO><moles:responsibleParties>' + \
178            '<moles:responsibleParty><moles:name>calum byrom</moles:name><moles:uri>www.cb.org</moles:uri><moles:role>Metadata maintainer</moles:role></moles:responsibleParty>' + \
179            '<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>' + \
180            '</moles:responsibleParties><moles:datasetLanguage>English</moles:datasetLanguage>' + \
181            '<moles:providerID>badc.nerc.ac.uk</moles:providerID>' + \
182            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \
183            '</moles:molesISO>' + \
184        '</moles:entity>' + \
185        '<category term="OZONE" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="OZONE MIXING RATIO (PPB )"/>' + \
186        '<category term="ERROR" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="ERROR FLAG (OZONE MIXING RATIO )"/>' + \
187        '<category term="HYDROGEN" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="HYDROGEN PEROXIDE PPBV"/>' + \
188        '<category term="ATOM_TYPE" scheme="GRAN - NOT YET SET UP/None/GRANULE" label="GRANULE"></category>' + \
189        '<summary>' + summaryText + '</summary>' + \
190        '<content src="' + csmlFile + '" type="application/xml"/>' + \
191        '<published>2008-06-17T10:15:19</published>' + \
192        '<moles:temporalRange>' + T1 + '/' + T2 + '</moles:temporalRange>' + \
193        '<georss:where><gml:Envelope><gml:lowerCorner>' + minX + ' ' + maxX + '</gml:lowerCorner><gml:upperCorner>' + minY + ' ' + maxY + '</gml:upperCorner></gml:Envelope></georss:where>' + \
194    '</entry>'
195
196   
197validAuthor = 'Tiddeman, David'
198validAuthors = [validAuthor + ' | www.cb.org', \
199                    'Brian Bandy | www.cb.org']
200   
201validGranuleAuthors = ['calum byrom | www.cb.org | Metadata maintainer', \
202                    'dom lowe | www.badc.rl.ac.uk | Metadata maintainer']
203
204validLinks = [linkHref1 + ' | WMS | http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026',\
205              linkHref2 + ' | alternate page | http://vocab.ndg.nerc.ac.uk/term/C330/0/NG02',
206              logoURL + ' | logo | LOGO - NOT YET SET UP',
207              '/db/moles_support/granuleAtom/famous_control_month_granule.moles']
208
Note: See TracBrowser for help on using the repository browser.