1 | ''' |
---|
2 | Created on 8 Mar 2012 |
---|
3 | |
---|
4 | @author: mnagni |
---|
5 | ''' |
---|
6 | import unittest |
---|
7 | from testconfig import MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT |
---|
8 | from MolesManager.moles3epb import Moles3EPB |
---|
9 | from libs.commons_db import DbManager |
---|
10 | from unittest import TestCase |
---|
11 | import logging |
---|
12 | from logging import StreamHandler |
---|
13 | from ea_model.iso_19115_2006_metadata_corrigendum.reference_system_information.md_identifier import MD_Identifier |
---|
14 | from test_utils import createObservationCollection |
---|
15 | from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection |
---|
16 | from ea_model.moles3_4.observationcollection.mo_observationcollection import MO_ObservationCollection |
---|
17 | from ea_model.iso_19115_2006_metadata_corrigendum.citation_and_responsible_party_information.ci_citation import CI_Citation |
---|
18 | |
---|
19 | |
---|
20 | class 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 | |
---|
53 | if __name__ == "__main__": |
---|
54 | #import sys;sys.argv = ['', 'Test.testName'] |
---|
55 | unittest.main() |
---|