1 | ''' |
---|
2 | Created on 7 Mar 2012 |
---|
3 | |
---|
4 | @author: mnagni |
---|
5 | ''' |
---|
6 | from unittest import TestCase |
---|
7 | from libs.commons_db import DbManager |
---|
8 | from libs.migration.MigrationEPB import MigrationEPB |
---|
9 | from libs.migration.processor.loadResources import LoadResources |
---|
10 | from libs.migration.db.classes import MigrationObject |
---|
11 | from libs.migration.processor.commons import DO_BADC, DS_pUBLISHED |
---|
12 | from MolesManager.moles3epb import Moles3EPB |
---|
13 | from libs.migration.processor.migrationProcess import MigrationProcess |
---|
14 | from testconfig import MIGRATION_DB_CONNECTION,\ |
---|
15 | MIGRATION_DB_SCRIPT, MOLES3_DB_SCRIPT, MOLES3_DB_CONNECTION |
---|
16 | |
---|
17 | class 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 | |
---|