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

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

Adjust Atom and MolesEntity? data models to properly use namespaces when
dealing with xpath queries - rather than having these stripped out. This
avoids problems when namespaces are given arbitrary names and is a more
exact, hence robust, approach.
Create new test class to put the xmlhandler2 tests separately in.
Add delete function to granulite - to allow data granules, and their
connections to data entities, to be removed + add 'roll back' functionality
to cope with scenarios when granulite replace/delete fails to complete
properly. Add new methods to the existdbclient to allow the restore/delete/backup
functionality.
Extend test suite to exercise new functionality.

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.models.vocabtermdata import VocabTermData as VTD
16import os
17
18BASE_DIR = 'ndgutilstests'
19
20curDir = os.getcwd()
21prefix = ''
22if not curDir.endswith(BASE_DIR):
23    prefix = '..' + os.sep
24   
25TEST_DATA_DIR = prefix + 'testdata' + os.sep
26DBCONFIG_FILE = TEST_DATA_DIR + 'exist.config'
27TEST_GRANULITE = TEST_DATA_DIR + 'example.granulite'
28
29NDG_CONFIG_FILE = TEST_DATA_DIR + 'ndgDiscovery.config'
30DIF_FILE = TEST_DATA_DIR + 'dataent_NDSC_DIF.xml'
31
32GRANULITE_TITLE = 'this is a new test granulite'
33GRANULITE_TIME_AXIS = 'time0'
34GRANULITE_CDML_DATASETID = 'test_hadgem1_dataset'
35GRANULITE_PROVIDER_ID = 'badc.nerc.ac.uk'
36GRANULITE_DATASETID = 'calum_data_set'
37GRANULITE_LOGO = 'http:/blah/blah/a_logo_icon.png'
38GRANULITE_AUTHOR_NAME = 'calum byrom'
39GRANULITE_AUTHOR_URI = 'www.cb.org'
40GRANULITE_AUTHOR_ROLE = 'Data migrator'
41GRANULITE_T1 = '1996-4-19'
42GRANULITE_T2 = '1998-9-22'
43
44VALID_REPOSITORY = "chinook.badc.rl.ac.uk"
45VALID_PROVIDER_ID = 'badc.nerc.ac.uk'
46VALID_MOLES_DOC_ID = 'dataent_hadisst'
47VALID_NDGA_DOC_ID = 'COAPEC_500YrRun_wholerun_annual_atmos'
48VALID_NUMSIM_DOC_ID = 'HadGEM1_CodeBase'
49VALID_ATOM_DOC_ID = 'dataent_11679938403412067'
50
51VALID_DISCOVERY_PROVIDER_ID = "csl.gov.uk"
52VALID_DISCOVERY_DOC_ID = "csl.gov.uk__1"       
53
54validParams = ['OZONE MIXING RATIO (PPB ) | http://vocab.ndg.nerc.ac.uk/blah | OZONE', \
55               'ERROR FLAG (OZONE MIXING RATIO ) | http://vocab.ndg.nerc.ac.uk/blah | ERROR', \
56               'HYDROGEN PEROXIDE PPBV | http://vocab.ndg.nerc.ac.uk/blah | HYDROGEN',
57               'CADMIUM >1.21 M DIAMETER (PMOL M-3) INSTRUMENTAL DETECTION LIMIT 0.132 NM']
58
59messyParams = ['OZONE MIXING RATIO &  (PPB     ) | http://vocab.ndg.nerc.ac.uk/blah | ozone', \
60               'ERROR FLAG (OZONE MIXING > RATIO  ) | http://vocab.ndg.nerc.ac.uk/blah | error', \
61               'Hydrogen Peroxide < ppbv | http://vocab.ndg.nerc.ac.uk/blah | hydrogen &']
62
63summaryText = 'this is a summary of the granulite'
64
65csmlFile = '/db/moles_support/csml/csml_famous_control_month.xml'
66
67logo = '/blah/blah/a_logo_icon.png'
68
69title = 'this is a test granulite'
70
71datasetID = 'famous_control_month_test_file'
72
73id = 'tag:localhost:5000,2008-09-17:/view/badc.nerc.ac.uk__ATOM__' + datasetID
74
75atomName = 'http://localhost:5000/view/badc.nerc.ac.uk__ATOM__' + datasetID
76
77name = datasetID + '.atom'
78
79VTD = VTD()
80T1 = '2792-12-16'
81T2 = '2992-11-16'
82minX = '-90.0'
83minY = '-90.0'
84maxX = '360.0'
85maxY = '5505.29980469'
86ABBREVIATION = 'BLAH'
87VALID_EMAIL = 'dt@bob.org'
88INVALID_EMAIL = 'dt.bob.org'
89INVALID_FILE = 'blah.txt'
90
91xmlString = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \
92    'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \
93    '<id>' + id + '</id>' + \
94    '<title>' + title + '</title>' + \
95        '<link href="' + atomName + '" rel="self"/>' + \
96        '<link href="http://badc.nerc.ac.uk/a-real-wms-endpoint" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \
97        '<link href="http://badc.nerc.ac.uk/alternate" rel="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" title="alternate page"/>' + \
98        '<link href="' + logo + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD/Logo"/>' + \
99        '<author><name>Tiddeman, David</name><email>' + VALID_EMAIL + '</email></author>' + \
100        '<contributor><name>Brian Bandy</name><email>bb@bb.org</email></contributor>' + \
101        '<moles:entity type="granule"><moles:molesISO><moles:responsibleParties>' + \
102            '<moles:responsibleParty><name>calum byrom</name><uri>www.cb.org</uri><role>Metadata maintainer</role></moles:responsibleParty>' + \
103            '<moles:responsibleParty><name>dom lowe</name><uri>www.badc.rl.ac.uk</uri><role>Metadata maintainer</role></moles:responsibleParty>' + \
104            '</moles:responsibleParties><moles:datasetLanguage>English</moles:datasetLanguage>' + \
105            '<moles:datasetLanguage>English</moles:datasetLanguage>' + \
106            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \
107            '<moles:abbreviation>' + ABBREVIATION + '</moles:abbreviation>' + \
108            '<moles:providerID>badc.nerc.ac.uk</moles:providerID>' + \
109            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \
110            '</moles:molesISO>' + \
111        '</moles:entity>' + \
112        '<category term="OZONE" scheme="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" label="OZONE MIXING RATIO (PPB )"/>' + \
113        '<category term="ERROR" scheme="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" label="ERROR FLAG (OZONE MIXING RATIO )"/>' + \
114        '<category term="HYDROGEN" scheme="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" label="HYDROGEN PEROXIDE PPBV"/>' + \
115        '<category term="ATOM_TYPE" scheme="GRAN - NOT YET SET UP/None/GRANULE" label="GRANULE"></category>' + \
116        '<summary>' + summaryText + '</summary>' + \
117        '<content src="' + csmlFile + '" type="application/xml"/>' + \
118        '<published>2008-06-17T10:15:19</published>' + \
119        '<moles:temporalRange>' + T1 + '/' + T2 + '</moles:temporalRange>' + \
120        '<georss:where><gml:Envelope><gml:lowerCorner>' + minX + ' ' + minY + '</gml:lowerCorner><gml:upperCorner>' + maxX + ' ' + maxY + '</gml:upperCorner></gml:Envelope></georss:where>' + \
121    '</entry>'
122
123invalidEmailXmlString = xmlString.replace(VALID_EMAIL, INVALID_EMAIL)
124
125INVALID_TITLE = '\xa2'
126invalidXmlString = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \
127    'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \
128    '<id>' + id + '</id>' + \
129        '<link href="' + atomName + '" rel="self"/>' + \
130        '<link href="http://badc.nerc.ac.uk/a-real-wms-endpoint" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \
131        '<link href="http://badc.nerc.ac.uk/alternate" rel="alternate" title="alternate page"/>' + \
132        '<link href="' + logo + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="' + VTD.LOGO_TERM + '"/>' + \
133        '<contributor><name>Brian Bandy</name><uri>www.cb.org</uri></contributor>' + \
134        '<moles:entity type="granule"><moles:molesISO><moles:responsibleParties>' + \
135            '<moles:responsibleParty><name>calum byrom</name><uri>www.cb.org</uri><role>Metadata maintainer</role></moles:responsibleParty>' + \
136            '<moles:responsibleParty><name>dom lowe</name><uri>www.badc.rl.ac.uk</uri><role>Metadata maintainer</role></moles:responsibleParty>' + \
137            '</moles:responsibleParties><moles:datasetLanguage>English</moles:datasetLanguage>' + \
138            '<moles:providerID>badc.nerc.ac.uk</moles:providerID>' + \
139            '<moles:metadataLanguage>English</moles:metadataLanguage>' + \
140            '</moles:molesISO>' + \
141        '</moles:entity>' + \
142        '<category term="OZONE" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="OZONE MIXING RATIO (PPB )"/>' + \
143        '<category term="ERROR" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="ERROR FLAG (OZONE MIXING RATIO )"/>' + \
144        '<category term="HYDROGEN" scheme="http://vocab.ndg.nerc.ac.uk/blah" label="HYDROGEN PEROXIDE PPBV"/>' + \
145        '<category term="ATOM_TYPE" scheme="GRAN - NOT YET SET UP/None/GRANULE" label="GRANULE"></category>' + \
146        '<summary>' + summaryText + '</summary>' + \
147        '<content src="' + csmlFile + '" type="application/xml"/>' + \
148        '<published>2008-06-17T10:15:19</published>' + \
149        '<moles:temporalRange>' + T1 + '/' + T2 + '</moles:temporalRange>' + \
150        '<georss:where><gml:Envelope><gml:lowerCorner>' + minX + ' ' + maxX + '</gml:lowerCorner><gml:upperCorner>' + minY + ' ' + maxY + '</gml:upperCorner></gml:Envelope></georss:where>' + \
151    '</entry>'
152
153   
154validAuthor = 'Tiddeman, David'
155validAuthors = [validAuthor + ' | www.cb.org', \
156                    'Brian Bandy | www.cb.org']
157   
158validGranuleAuthors = ['calum byrom | www.cb.org | Metadata maintainer', \
159                    'dom lowe | www.badc.rl.ac.uk | Metadata maintainer']
160
161validLinks = ['http://badc.nerc.ac.uk/a-real-wms-endpoint | WMS | http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026',\
162              'http://badc.nerc.ac.uk/alternate | alternate page | alternate',
163              '/blah/blah/a_logo_icon.png | logo | LOGO - NOT YET SET UP',
164              '/db/moles_support/granuleAtom/famous_control_month_granule.moles']
165
Note: See TracBrowser for help on using the repository browser.