source: mauRepo/MolesManager/trunk/src/libs/migration/tests/moles3epbmothods.py @ 8198

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/libs/migration/tests/moles3epbmothods.py@8198
Revision 8198, 2.2 KB checked in by mnagni, 9 years ago (diff)

Complete - # 22418: CEDA Observation - moles2 link
 http://team.ceda.ac.uk/trac/ceda/ticket/22418
Complete - # 22397: CEDA Observation geographicExtent
 http://team.ceda.ac.uk/trac/ceda/ticket/22397
Incomplete - # 22412: CEDA Observation - publisher, curator
 http://team.ceda.ac.uk/trac/ceda/ticket/22412

Line 
1'''
2Created on 8 Mar 2012
3
4@author: mnagni
5'''
6import unittest
7from testconfig import MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT
8from MolesManager.moles3epb import Moles3EPB
9from libs.commons_db import DbManager
10from unittest import TestCase
11import logging
12from logging import StreamHandler
13from ea_model.iso_19115_2006_metadata_corrigendum.reference_system_information.md_identifier import MD_Identifier
14from test_utils import createObservationCollection
15from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection
16from ea_model.moles3_4.observationcollection.mo_observationcollection import MO_ObservationCollection
17from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_citation import CI_Citation
18
19
20class Moles3EPBTest(TestCase):
21
22    def setUp(self):   
23        Moles3EPBTest.molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT)
24        Moles3EPB.overrrideDBManager(Moles3EPBTest.molesDB)
25        self.logging = logging.getLogger('Moles3EPBTest')
26        self.logging.addHandler(StreamHandler())
27        self.logging.setLevel(logging.DEBUG)
28
29    def tearDown(self):
30        pass
31        #self._dropAllTables()
32
33    def runTest(self):
34        self.checkExtractCollectionIdentifierByTitle()       
35
36    def checkExtractCollectionIdentifierByTitle(self):
37        session = Moles3EPB.getNewMolesSession();
38        observationCollection = createObservationCollection()
39       
40        self.logging.info('Stores an new CEDA_ObservationCollection')
41        Moles3EPB.addCedaObject(observationCollection, session)
42        session.commit()
43
44        my_identifier = Moles3EPB.extractCollectionIdentifierByTitle('test_title', session)           
45        self.assertTrue(my_identifier.count() > 0, "Cannot find MD_Identifier")
46        my_identifier = Moles3EPB.extractCollectionIdentifierByTitle('fake_title', session)       
47        self.assertTrue(my_identifier.count() == 0, "Cannot find MD_Identifier")           
48       
49        self.logging.info('Deletes it')
50        session.delete(observationCollection)
51        session.commit()
52
53if __name__ == "__main__":
54    #import sys;sys.argv = ['', 'Test.testName']
55    unittest.main()
Note: See TracBrowser for help on using the repository browser.