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 MigrationEPBFactory |
---|
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, DS_PUBLISHED |
---|
12 | from MolesManager.moles3epb import Moles3EPBFactory |
---|
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, INFO_DB_CONNECTION |
---|
16 | from libs.migration.InfodbEPB import InfodbEPBFactory |
---|
17 | from MolesManager.settings import EVENTS_DB |
---|
18 | from libs.migration.client import EPBRepo |
---|
19 | |
---|
20 | class LoadResourceTest(TestCase): |
---|
21 | ''' |
---|
22 | classdocs |
---|
23 | ''' |
---|
24 | |
---|
25 | def setUp(self): |
---|
26 | migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT, sql_echo=True) |
---|
27 | #migrationDB = DbManager(MIGRATION_DB_CONNECTION, MIGRATION_DB_SCRIPT) |
---|
28 | #MigrationEPB.overrrideDBManager(migrationDB) |
---|
29 | |
---|
30 | molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, sql_echo=True, session_event_manager=EVENTS_DB) |
---|
31 | #molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT, session_event_manager=EVENTS_DB) |
---|
32 | |
---|
33 | |
---|
34 | #infoDB = DbManager(INFO_DB_CONNECTION, sql_echo=True) |
---|
35 | infoDB = DbManager(INFO_DB_CONNECTION) |
---|
36 | infoFactory = InfodbEPBFactory(infoDB) |
---|
37 | |
---|
38 | moles3Factory = Moles3EPBFactory(molesDB) |
---|
39 | migrationFactory = MigrationEPBFactory(migrationDB) |
---|
40 | |
---|
41 | EPBRepo.moles3EPB = moles3Factory.createEPB() |
---|
42 | EPBRepo.migrationEPB = migrationFactory.createEPB() |
---|
43 | EPBRepo.infodbEPB = infoFactory.createEPB() |
---|
44 | ''' |
---|
45 | lr = LoadResources() |
---|
46 | ex = lr.process() |
---|
47 | for e in ex: |
---|
48 | print e |
---|
49 | ''' |
---|
50 | def testMigrationProcess(self): |
---|
51 | mp = MigrationProcess() |
---|
52 | |
---|
53 | dataEntity = MigrationObject() |
---|
54 | dataEntity.doc_owner = DO_BADC |
---|
55 | |
---|
56 | #dataEntity.doc_status = DS_pUBLISHED |
---|
57 | #dataEntity.doc_name = 'dataent_csip.atom' |
---|
58 | |
---|
59 | #Has a DOI |
---|
60 | #dataEntity.doc_status = DS_PUBLISHED |
---|
61 | #dataEntity.doc_name = 'DE_095e8da2-cf02-11e0-8b7a-00e081470265.atom' |
---|
62 | |
---|
63 | #Has 3 DOI |
---|
64 | dataEntity.doc_status = DS_pUBLISHED |
---|
65 | dataEntity.doc_name = 'dataent_chobs.atom' |
---|
66 | |
---|
67 | |
---|
68 | ex = mp.process(dataEntity) |
---|
69 | #ex = [] |
---|
70 | #ex = mp.process() |
---|
71 | for e in ex: |
---|
72 | print e |
---|
73 | #self._dropAllTables() |
---|
74 | |
---|
75 | """ |
---|
76 | def _dropAllTables(self): |
---|
77 | session = Moles3EPB.getNewMolesSession() |
---|
78 | f = open('dropAllTables.sql', 'r') |
---|
79 | for line in f.readlines(): |
---|
80 | stripped = line.strip() |
---|
81 | if len(stripped) > 0: |
---|
82 | Moles3EPB.executeNative(line.strip(), session) |
---|
83 | session.commit() |
---|
84 | session.close() |
---|
85 | """ |
---|
86 | |
---|
87 | |
---|