source: mauRepo/MolesManager/trunk/cedaMoles/tests/migration/migrationprocess.py @ 8537

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

Incomplete - # 22528: Migration of FAtCat Open Search link for HPFeld
 http://team.ceda.ac.uk/trac/ceda/ticket/22528

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 cedaMoles.libs.commons_db import DbManager
35from cedaMoles.libs.migration.MigrationEPB import MigrationEPBFactory
36from cedaMoles.libs.migration.processor.loadResources import LoadResources
37from cedaMoles.libs.migration.db.classes import MigrationObject
38from cedaMoles.libs.migration.processor.commons import DO_BADC, DS_pUBLISHED, DS_PUBLISHED,\
39    DO_NEODC
40from cedaMoles.MolesManager.moles3epb import Moles3EPBFactory
41from cedaMoles.libs.migration.processor.migrationProcess import MigrationProcess
42from cedaMoles.libs.migration.InfodbEPB import InfodbEPBFactory
43from cedaMoles.libs.migration.client import EPBRepo, generateMigrationReport
44from cedaMoles.tests.testconfig import MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT,\
45    MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, INFO_DB_CONNECTION, EVENTS_DB
46
47class LoadResourceTest(TestCase):
48    '''
49    classdocs
50    '''
51   
52    def setUp(self):
53        migration_db = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT, 
54                                 sql_echo=True)     
55        moles_db = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, 
56                             sql_echo=True, session_event_manager=EVENTS_DB)                         
57        info_db = DbManager(INFO_DB_CONNECTION)
58               
59        infoFactory = InfodbEPBFactory(info_db)       
60        moles3Factory = Moles3EPBFactory(moles_db)
61        migrationFactory = MigrationEPBFactory(migration_db)
62
63        self.epbRepo = EPBRepo(moles3Factory.createEPB() , \
64                               migrationFactory.createEPB(), \
65                               infoFactory.createEPB())
66
67        if False:
68            lr = LoadResources(self.epbRepo)
69            ex = lr.process()
70            for e in ex:
71                print e
72               
73        self.mp = MigrationProcess(self.epbRepo)
74
75    def testMigrationProcess(self):                       
76        #dataEntity.doc_status = DS_pUBLISHED
77        #dataEntity.doc_name = 'dataent_csip.atom'
78       
79        #Has a DOI
80        #dataEntity.doc_status = DS_PUBLISHED
81        #dataEntity.doc_name = 'DE_095e8da2-cf02-11e0-8b7a-00e081470265.atom'
82       
83        #Has 3 DOI
84        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_chobs.atom')
85       
86        #IASI
87        #self.processDataEntity(DO_NEODC, DS_pUBLISHED, 'dataent_12417810458627666.atom')
88        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_VIRTEM.atom')
89        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12162569915925921.atom')
90             
91        #ECMWF
92        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-ERA.atom')
93        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-OP.atom')
94        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12458543158227759.atom')               
95        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-E40.atom')
96        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-TRJ.atom')
97       
98       
99        #self.processDataEntity(DO_NEODC, DS_pUBLISHED, 'dataent_11750994700119761.atom')
100        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-TRJ.atom')
101        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_UGAMPO3.atom')
102        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12282368470627062.atom')   
103        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_11744364633818458.atom')       
104        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_11744364633818458.atom')
105       
106        #Infrared Atmospheric Sounding Interferometer (IASI)
107        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12417810458627666.atom')
108       
109                             
110                                     
111        #self.processDataEntity()             
112
113       
114    def processDataEntity(self, doc_owner = None, doc_status = None, doc_name = None):
115        dataEntity = None
116        if doc_owner is not None and doc_status is not None and doc_name is not None:
117            dataEntity = MigrationObject()
118            dataEntity.doc_owner = doc_owner       
119            dataEntity.doc_status = doc_status
120            dataEntity.doc_name = doc_name
121        ex = self.mp.process(dataEntity)
122        generateMigrationReport(ex)
123
Note: See TracBrowser for help on using the repository browser.