source: mauRepo/MolesManager/trunk/src/libs/migration/tests/migrationprocess.py @ 8362

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

Fixes a bug in geographicalExtension migration

Line 
1'''
2BSD Licence
3Copyright (c) 2012, Science & Technology Facilities Council (STFC)
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without modification,
7are permitted provided that the following conditions are met:
8
9    * Redistributions of source code must retain the above copyright notice,
10        this list of conditions and the following disclaimer.
11    * Redistributions in binary form must reproduce the above copyright notice,
12        this list of conditions and the following disclaimer in the documentation
13        and/or other materials provided with the distribution.
14    * Neither the name of the Science & Technology Facilities Council (STFC)
15        nor the names of its contributors may be used to endorse or promote
16        products derived from this software without specific prior written permission.
17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29Created on 7 Mar 2012
30
31@author: Maurizio Nagni
32'''
33from unittest import TestCase
34from libs.commons_db import DbManager
35from libs.migration.MigrationEPB import MigrationEPBFactory
36from libs.migration.processor.loadResources import LoadResources
37from libs.migration.db.classes import MigrationObject
38from libs.migration.processor.commons import DO_BADC, DS_pUBLISHED, DS_PUBLISHED,\
39    DO_NEODC
40from MolesManager.moles3epb import Moles3EPBFactory
41from libs.migration.processor.migrationProcess import MigrationProcess
42from testconfig import MIGRATION_DB_CONNECTION,\
43    MIGRATION_DB_SCRIPT, MOLES3_DB_SCRIPT, MOLES3_DB_CONNECTION, INFO_DB_CONNECTION
44from libs.migration.InfodbEPB import InfodbEPBFactory
45from MolesManager.settings import EVENTS_DB
46from libs.migration.client import EPBRepo
47
48class LoadResourceTest(TestCase):
49    '''
50    classdocs
51    '''
52   
53    def setUp(self):
54        migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT, sql_echo=True)
55        #migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT)
56        #MigrationEPB.overrrideDBManager(migrationDB)     
57
58        molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, sql_echo=True, session_event_manager=EVENTS_DB)
59        #molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, session_event_manager=EVENTS_DB)         
60       
61       
62        #infoDB = DbManager(INFO_DB_CONNECTION, sql_echo=True)
63        infoDB = DbManager(INFO_DB_CONNECTION)       
64        infoFactory = InfodbEPBFactory(infoDB)
65       
66        moles3Factory = Moles3EPBFactory(molesDB)
67        migrationFactory = MigrationEPBFactory(migrationDB)
68
69        self.epbRepo = EPBRepo(moles3Factory.createEPB() , \
70                               migrationFactory.createEPB(), \
71                               infoFactory.createEPB())
72
73        if False:
74            lr = LoadResources(self.epbRepo)
75            ex = lr.process()
76            for e in ex:
77                print e
78               
79        self.mp = MigrationProcess(self.epbRepo)
80
81    def testMigrationProcess(self):                       
82        #dataEntity.doc_status = DS_pUBLISHED
83        #dataEntity.doc_name = 'dataent_csip.atom'
84       
85        #Has a DOI
86        #dataEntity.doc_status = DS_PUBLISHED
87        #dataEntity.doc_name = 'DE_095e8da2-cf02-11e0-8b7a-00e081470265.atom'
88       
89        #Has 3 DOI
90        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_chobs.atom')
91       
92        #IASI
93        self.processDataEntity(DO_NEODC, DS_pUBLISHED, 'dataent_12417810458627666.atom')
94        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_VIRTEM.atom')
95        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12162569915925921.atom')
96             
97        #ECMWF
98        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-ERA.atom')
99        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-OP.atom')
100        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12458543158227759.atom')               
101        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-E40.atom')
102        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-TRJ.atom')               
103
104       
105    def processDataEntity(self, doc_owner, doc_status, doc_name):
106        dataEntity = MigrationObject()
107        dataEntity.doc_owner = doc_owner       
108        dataEntity.doc_status = doc_status
109        dataEntity.doc_name = doc_name
110        ex = self.mp.process(dataEntity)
111        for e in ex:
112            print e
113       
114
Note: See TracBrowser for help on using the repository browser.