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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/cedaMoles/tests/migration/migrationprocess.py@8522
Revision 8522, 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
Incomplete - # 22534: Add versiojn number to the gui page
 http://team.ceda.ac.uk/trac/ceda/ticket/22534

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        migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT, sql_echo=True)     
54        molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, sql_echo=True, session_event_manager=EVENTS_DB)                         
55        infoDB = DbManager(INFO_DB_CONNECTION)
56               
57        infoFactory = InfodbEPBFactory(infoDB)       
58        moles3Factory = Moles3EPBFactory(molesDB)
59        migrationFactory = MigrationEPBFactory(migrationDB)
60
61        self.epbRepo = EPBRepo(moles3Factory.createEPB() , \
62                               migrationFactory.createEPB(), \
63                               infoFactory.createEPB())
64
65        if False:
66            lr = LoadResources(self.epbRepo)
67            ex = lr.process()
68            for e in ex:
69                print e
70               
71        self.mp = MigrationProcess(self.epbRepo)
72
73    def testMigrationProcess(self):                       
74        #dataEntity.doc_status = DS_pUBLISHED
75        #dataEntity.doc_name = 'dataent_csip.atom'
76       
77        #Has a DOI
78        #dataEntity.doc_status = DS_PUBLISHED
79        #dataEntity.doc_name = 'DE_095e8da2-cf02-11e0-8b7a-00e081470265.atom'
80       
81        #Has 3 DOI
82        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_chobs.atom')
83       
84        #IASI
85        #self.processDataEntity(DO_NEODC, DS_pUBLISHED, 'dataent_12417810458627666.atom')
86        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_VIRTEM.atom')
87        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12162569915925921.atom')
88             
89        #ECMWF
90        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-ERA.atom')
91        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-OP.atom')
92        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12458543158227759.atom')               
93        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-E40.atom')
94        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-TRJ.atom')
95       
96       
97        #self.processDataEntity(DO_NEODC, DS_pUBLISHED, 'dataent_11750994700119761.atom')
98        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_ECMWF-TRJ.atom')
99        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_UGAMPO3.atom')
100        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12282368470627062.atom')   
101        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_11744364633818458.atom')       
102        #self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_11744364633818458.atom')
103       
104        #Infrared Atmospheric Sounding Interferometer (IASI)
105        self.processDataEntity(DO_BADC, DS_pUBLISHED, 'dataent_12417810458627666.atom')
106       
107                             
108                                     
109        #self.processDataEntity()             
110
111       
112    def processDataEntity(self, doc_owner = None, doc_status = None, doc_name = None):
113        dataEntity = None
114        if doc_owner is not None and doc_status is not None and doc_name is not None:
115            dataEntity = MigrationObject()
116            dataEntity.doc_owner = doc_owner       
117            dataEntity.doc_status = doc_status
118            dataEntity.doc_name = doc_name
119        ex = self.mp.process(dataEntity)
120        generateMigrationReport(ex)
121
Note: See TracBrowser for help on using the repository browser.