Changeset 4937 for ndgCommon/trunk/ndg


Ignore:
Timestamp:
10/02/09 17:40:45 (11 years ago)
Author:
cbyrom
Message:

Extend test constants to improve available data for use in tests + add
new utility method to create old moles docs to use with old code tests.

Location:
ndgCommon/trunk/ndg/common/unittests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/unittests/noseTests.py

    r4793 r4937  
    1414 
    1515import nose, logging 
    16 logging.basicConfig(level=logging.DEBUG,\ 
     16logging.basicConfig(level=logging.WARNING,\ 
    1717                    format='%(asctime)s %(filename)s:%(lineno)d %(levelname)s %(message)s') 
    1818 
  • ndgCommon/trunk/ndg/common/unittests/passwords.txt

    r4793 r4937  
     1localhost admin pass01word 
    12glue.badc.rl.ac.uk admin molesadmin 
    23chinook.badc.rl.ac.uk admin molesadmin 
    3 localhost admin pass01word 
  • ndgCommon/trunk/ndg/common/unittests/testconstants.py

    r4849 r4937  
    1313__revision__ = '$Id: $' 
    1414 
    15 from ndg.common.src.clients.xmldb.eXist.eXistConnector import eXistConnector as ec 
    1615from ndg.common.src.models.vocabtermdata import VocabTermData as VTD 
    1716import os, datetime 
    1817 
    1918BASE_DIR = 'unittests' 
     19 
     20# environment variable - which may need to be unset to get some tests (notably 
     21# involving feedparser) working     
     22PROXY_KEY = 'http_proxy' 
    2023 
    2124def getTestDataDir(dir): 
     
    3437parentDir = '..' + os.sep 
    3538TEST_DATA_DIR = getTestDataDir('testdata' + os.sep) 
    36      
    37  
    38  
     39 
     40 
     41TEST_COLLECTION_PATH = '/db/testcollection' 
     42TEST_FILE_NAME = 'testfile.xml' 
     43TEST_FILE_PATH = TEST_COLLECTION_PATH + '/' + TEST_FILE_NAME 
     44 
     45EXIST_DB = 'chinook.badc.rl.ac.uk' 
    3946PG_DBCONFIG_FILE = TEST_DATA_DIR + 'pg.config' 
    4047EXIST_DBCONFIG_FILE = TEST_DATA_DIR + 'exist.config' 
    4148TEST_GRANULITE = TEST_DATA_DIR + '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 
    4253 
    4354NDG_CONFIG_FILE = TEST_DATA_DIR + 'ndgDiscovery.config' 
     
    4859GRANULITE_CDML_DATASETID = 'test_hadgem1_dataset' 
    4960GRANULITE_PROVIDER_ID = 'badc.nerc.ac.uk' 
     61GRANULITE_PROVIDER_ID2 = 'neodc.nerc.ac.uk' 
    5062GRANULITE_DATASETID = 'calum_data_set' 
    5163GRANULITE_LOGO = 'http:/blah/blah/a_logo_icon.png' 
     
    5668GRANULITE_T2 = '1998-9-22' 
    5769 
    58 VALID_DISCOVERY_URL = 'http://ndgbeta.badc.rl.ac.uk/view/badc.nerc.ac.uk__NDG-B1__dataent_hadisst' 
    59 VALID_RETRIEVE_URL = 'http://ndgbeta.badc.rl.ac.uk/retrieve/badc.nerc.ac.uk__NDG-B1__dataent_hadisst' 
     70INVALID_XQUERY = "for $DE in collection('blah') return $DE" 
     71 
     72INVALID_NDG_URL = 'badc.nerc.ac.uk__NDG-B1__dataent_hadisstBLAHH' 
     73VALID_DISCOVERY_URL = 'http://ndgbeta.badc.rl.ac.uk/view/' + VALID_NDG_URL 
     74VALID_RETRIEVE_URL = 'http://ndgbeta.badc.rl.ac.uk/retrieve/' + VALID_NDG_URL 
     75INVALID_URL = 'http://invalid.blah.com' 
     76VALID_DISCOVERY_URL2 = 'http://ndgbeta.badc.rl.ac.uk/view/badc.nerc.ac.uk__ATOM__famous_control_month_test_file' 
    6077 
    6178VALID_REPOSITORY = "chinook.badc.rl.ac.uk" 
    62 VALID_PROVIDER_ID = 'badc.nerc.ac.uk' 
    6379VALID_MOLES_DOC_ID = 'dataent_hadisst' 
    6480VALID_NDGA_DOC_ID = 'COAPEC_500YrRun_wholerun_annual_atmos' 
     
    8298csmlFile = '/db/moles_support/csml/csml_famous_control_month.xml' 
    8399 
    84 logo = '/blah/blah/a_logo_icon.png' 
     100logoURL = 'http://www.tessella.com/wp-content/themes/tessella/images/Tessella_Logo.png' 
    85101 
    86102title = 'this is a test granulite' 
    87103 
    88104datasetID = 'famous_control_month_test_file' 
    89  
    90 id = 'tag:localhost:5000,2008-09-17:/view/badc.nerc.ac.uk__ATOM__' + datasetID 
    91  
    92 atomName = 'http://localhost:5000/view/badc.nerc.ac.uk__ATOM__' + datasetID 
     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 
    93112 
    94113name = datasetID + '.atom' 
     
    105124INVALID_EMAIL = 'dt.bob.org' 
    106125INVALID_FILE = 'blah.txt' 
     126INVALID_COLLECTION = '/db/gooseberry' 
    107127createdDate = datetime.datetime.today().strftime("%Y-%m-%dT%H_%M_%S") 
    108128 
     
    120140        '</moles:entity>' 
    121141         
     142linkHref1 = 'http://www.tessella.com/' 
     143linkHref2 = 'http://www.tessella.com' 
     144 
    122145xmlString = '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \ 
    123146    'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \ 
     
    125148    '<title>' + title + '</title>' + \ 
    126149        '<link href="' + atomName + '" rel="self"/>' + \ 
    127         '<link href="http://badc.nerc.ac.uk/a-real-wms-endpoint" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \ 
    128         '<link href="http://badc.nerc.ac.uk/alternate" rel="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" title="alternate page"/>' + \ 
    129         '<link href="' + logo + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD/Logo"/>' + \ 
     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"/>' + \ 
    130153        '<author><name>Tiddeman, David</name><email>' + VALID_EMAIL + '</email></author>' + \ 
    131154        '<contributor><name>Brian Bandy</name><email>bb@bb.org</email></contributor>' + \ 
    132155        MOLES_ENTITY_STRING + \ 
    133         '<category term="OZONE" scheme="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" label="OZONE MIXING RATIO (PPB )"/>' + \ 
    134         '<category term="ERROR" scheme="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" label="ERROR FLAG (OZONE MIXING RATIO )"/>' + \ 
    135         '<category term="HYDROGEN" scheme="http://vocab.ndg.nerc.ac.uk/term/C110/6/GD" label="HYDROGEN PEROXIDE PPBV"/>' + \ 
     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"/>' + \ 
    136159        '<category term="ATOM_TYPE" scheme="GRAN - NOT YET SET UP/None/GRANULE" label="GRANULE"></category>' + \ 
    137160        '<summary>' + summaryText + '</summary>' + \ 
     
    151174        '<link href="http://badc.nerc.ac.uk/a-real-wms-endpoint" rel="http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026" title="WMS"/>' + \ 
    152175        '<link href="http://badc.nerc.ac.uk/alternate" rel="alternate" title="alternate page"/>' + \ 
    153         '<link href="' + logo + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="' + VTD.LOGO_TERM + '"/>' + \ 
     176        '<link href="' + logoURL + '" title="' + VTD.TERM_DATA[VTD.LOGO_TERM].title + '" rel="' + VTD.LOGO_TERM + '"/>' + \ 
    154177        '<contributor><name>Brian Bandy</name><uri>www.cb.org</uri></contributor>' + \ 
    155178        '<moles:entity type="granule"><moles:molesISO><moles:responsibleParties>' + \ 
     
    180203                    'dom lowe | www.badc.rl.ac.uk | Metadata maintainer'] 
    181204 
    182 validLinks = ['http://badc.nerc.ac.uk/a-real-wms-endpoint | WMS | http://vocab.ndg.nerc.ac.uk/term/P201/1/GCMDU026',\ 
    183               'http://badc.nerc.ac.uk/alternate | alternate page | alternate', 
    184               '/blah/blah/a_logo_icon.png | logo | LOGO - NOT YET SET UP', 
     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', 
    185208              '/db/moles_support/granuleAtom/famous_control_month_granule.moles'] 
    186209 
  • ndgCommon/trunk/ndg/common/unittests/testutils.py

    r4793 r4937  
    1414 
    1515from ndg.common.src.models.vocabtermdata import VocabTermData as VTD 
    16 import ndg.common.src.clients.xmldb.eXist.existdbclient as dbc 
     16from ndg.common.src.clients.xmldb.eXist.atomclient import AtomClient as ac 
     17import ndg.common.src.clients.xmldb.eXist.dbconstants as dc 
    1718from ndg.common.src.models.Atom import Atom 
     19import ndg.common.unittests.testconstants as tc 
     20import os 
    1821 
    1922class testUtils(object): 
    2023    def __init__(self, confFile): 
    21         self.dbc = dbc.eXistDBClient(configFile = confFile, setUpDB = True) 
     24        self.host = tc.EXIST_DB 
     25        self.ac = ac(dbHostName = self.host, configFileName = confFile, setUpDB = True) 
    2226     
    2327    def createAtom(self, content): 
     
    2832    def createAtomInEXist(self, content): 
    2933        atom = self.createAtom(content) 
    30         return self.dbc.createAtomInExist(atom) 
     34        return self.ac.createAtom(atom) 
    3135     
    32     def deleteAtomInExist(self, path): 
    33         self.dbc.deleteEXistFile(path) 
     36    def deleteDoc(self, path): 
     37        self.ac.deleteDoc(path) 
     38         
     39    def createOldMolesDoc(self): 
     40        ''' 
     41        Create an old moles1.0 doc 
     42        ''' 
     43        # firstly, load a moles do to eXist 
     44        f = open(tc.MOLES_FILE_NAME, 'r') 
     45        xml = f.read() 
     46        f.close() 
     47        fileName = f.name.split(os.sep)[-1] 
     48        path = dc.MOLES_COLLECTION_PATH + tc.GRANULITE_PROVIDER_ID 
     49        self.ac.createDoc(xml, path, fileName) 
     50        return path 
Note: See TracChangeset for help on using the changeset viewer.