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

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

Incomplete - # 22385: CEDA Observation - result
 http://team.ceda.ac.uk/trac/ceda/ticket/22385

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, INFO_DB_CONNECTION
16from libs.migration.InfodbEPB import InfodbEPB
17
18class LoadResourceTest(TestCase):
19    '''
20    classdocs
21    '''
22
23    def setUp(self):
24        #self._dropAllTables()
25       
26        migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT)
27        MigrationEPB.overrrideDBManager(migrationDB)       
28
29        molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT)
30        Moles3EPB.overrrideDBManager(molesDB)
31       
32        infoDB = DbManager(INFO_DB_CONNECTION)
33        InfodbEPB.overrrideDBManager(infoDB)
34       
35        lr = LoadResources()
36        ex = []
37        ex = lr.process()
38        for e in ex:
39            print e
40         
41
42    def testMigrationProcess(self):
43        mp = MigrationProcess()
44
45        dataEntity = MigrationObject()
46        dataEntity.doc_status = DS_pUBLISHED
47        dataEntity.doc_owner = DO_BADC
48        dataEntity.doc_name = 'dataent_csip.atom'
49        #dataEntity.doc_name = 'DE_dcaa78b2-4008-11e0-88c9-00e081470265.atom'
50       
51        ex = mp.process(dataEntity)
52        ex = mp.process()
53        for e in ex:
54            print e
55       
56    def _dropAllTables(self):
57        molesDB = DbManager(MOLES3_DB_CONNECTION, None)
58        Moles3EPB.overrrideDBManager(molesDB)
59        session = Moles3EPB.getNewMolesSession()
60        f = open('dropAllTables.sql', 'r')
61        for line in f.readlines():
62            stripped = line.strip()
63            if len(stripped) > 0:
64                Moles3EPB.executeNative(line.strip())
65        session.commit()
66        session.close()
67        molesDB = None       
68       
69       
70       
Note: See TracBrowser for help on using the repository browser.