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

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

Complete - # 22418: CEDA Observation - moles2 link
 http://team.ceda.ac.uk/trac/ceda/ticket/22418
Complete - # 22397: CEDA Observation geographicExtent
 http://team.ceda.ac.uk/trac/ceda/ticket/22397
Incomplete - # 22412: CEDA Observation - publisher, curator
 http://team.ceda.ac.uk/trac/ceda/ticket/22412

Line 
1'''
2Created on 7 Mar 2012
3
4@author: mnagni
5'''
6from unittest import TestCase
7from libs.commons_db import DbManager
8from libs.migration.MigrationEPB import MigrationEPB
9from libs.migration.processor.loadResources import LoadResources
10from libs.migration.db.classes import MigrationObject
11from libs.migration.processor.commons import DO_BADC, DS_pUBLISHED
12from MolesManager.moles3epb import Moles3EPB
13from libs.migration.processor.migrationProcess import MigrationProcess
14from testconfig import MIGRATION_DB_CONNECTION,\
15    MIGRATION_DB_SCRIPT, MOLES3_DB_SCRIPT, MOLES3_DB_CONNECTION
16
17class LoadResourceTest(TestCase):
18    '''
19    classdocs
20    '''
21
22    def setUp(self):
23        #self._dropAllTables()
24       
25        migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT)
26        MigrationEPB.overrrideDBManager(migrationDB)       
27
28        molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT)
29        Moles3EPB.overrrideDBManager(molesDB)
30       
31        lr = LoadResources()
32        ex = []
33        ex = lr.process()
34        for e in ex:
35            print e
36         
37
38    def testMigrationProcess(self):
39        mp = MigrationProcess()
40
41        dataEntity = MigrationObject()
42        dataEntity.doc_status = DS_pUBLISHED
43        dataEntity.doc_owner = DO_BADC
44        dataEntity.doc_name = 'dataent_csip.atom'
45        #dataEntity.doc_name = 'DE_dcaa78b2-4008-11e0-88c9-00e081470265.atom'
46       
47        ex = mp.process(dataEntity)
48        #ex = mp.process()
49        for e in ex:
50            print e
51       
52    def _dropAllTables(self):
53        molesDB = DbManager(MOLES3_DB_CONNECTION, None)
54        Moles3EPB.overrrideDBManager(molesDB)
55        session = Moles3EPB.getNewMolesSession()
56        f = open('dropAllTables.sql', 'r')
57        for line in f.readlines():
58            stripped = line.strip()
59            if len(stripped) > 0:
60                Moles3EPB.executeNative(line.strip())
61        session.commit()
62        session.close()
63        molesDB = None       
64       
65       
66       
Note: See TracBrowser for help on using the repository browser.