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

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

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