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

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

CEDA_Observations were not correctly added to CEDA_ObservationCollection.member

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