Browse Source

Suppression de sqlutils.getEngine au profit de sqlutils.get_engine

Roland Haroutiounian 9 years ago
parent
commit
b03958a65a

+ 1
- 1
Database/sqlsetup.py View File

@@ -7,7 +7,7 @@ from Database import sqlutils
7 7
 
8 8
 def init_db(dbconfname='default', alchemy_logs=None, schema=None):
9 9
 
10
-    dbe = sqlutils.getEngine(dbconfname, alchemy_logs)
10
+    dbe = sqlutils.get_engine(dbconfname, alchemy_logs)
11 11
     meta = sqlutils.meta(dbe)
12 12
     meta.reflect()
13 13
     meta.drop_all(dbe)

+ 0
- 4
Database/sqlutils.py View File

@@ -62,10 +62,6 @@ def get_engine(ename='default', sqlalogging=None):
62 62
     return ret
63 63
 
64 64
 
65
-def getEngine(ename='default', sqlalogging=None):
66
-    return get_engine(ename=ename, sqlalogging=sqlalogging)
67
-
68
-
69 65
 ## Return a sqlalchemy.MetaData object
70 66
 # @param engine sqlalchemy.engine : A sqlalchemy engine
71 67
 # @return an sql alechemy MetaData instance bind to engine

+ 1
- 1
EditorialModel/components.py View File

@@ -132,7 +132,7 @@ class EmComponent(object):
132 132
     @classmethod
133 133
     ## Shortcut that return the sqlAlchemy engine
134 134
     def db_engine(cls):
135
-        return sqlutils.getEngine(cls.dbconf)
135
+        return sqlutils.get_engine(cls.dbconf)
136 136
 
137 137
     ## Do the query on the database for EmComponent::populate()
138 138
     # @throw EmComponentNotExistError if the instance is not anymore stored in database

+ 4
- 4
EditorialModel/test/test_classes.py View File

@@ -54,7 +54,7 @@ class TestEmClassCreation(ClassesTestCase):
54 54
     # should be able to select on the created table
55 55
     def test_table_em_classes(self):
56 56
         """ Testing ability of EmClass to crate its associated table """
57
-        conn = sqlutils.getEngine().connect()
57
+        conn = sqlutils.get_engine().connect()
58 58
         a = sqlutils.meta(conn)
59 59
         try:
60 60
             newtable = sqla.Table('testClass', sqlutils.meta(conn))
@@ -97,7 +97,7 @@ class TestEmClassDeletion(ClassesTestCase):
97 97
     # test if the table is deleted after a call to delete
98 98
     def test_table_delete(self):
99 99
         """ Test associated table deletetion on EmClass deletion """
100
-        dbe = sqlutils.getEngine()
100
+        dbe = sqlutils.get_engine()
101 101
         for i,class_name in enumerate(self.names):
102 102
             cur_class = EmClass(class_name)
103 103
             self.assertTrue(cur_class.delete(), "delete method didn't return True but the class has no fieldgroups")
@@ -117,7 +117,7 @@ class TestEmClassDeletion(ClassesTestCase):
117 117
         test_class = EmClass(self.names[0])
118 118
         fieldgroup = EmFieldGroup.create('fooFieldGroup', test_class)
119 119
         self.assertFalse(test_class.delete(), "delete method returns True but the class has fieldgroup")
120
-        dbe = sqlutils.getEngine()
120
+        dbe = sqlutils.get_engine()
121 121
         meta = sqlutils.meta(dbe)
122 122
         self.assertIn(self.names[0], meta.tables, "Table has been deleted but the class has fieldgroup")
123 123
         try:
@@ -237,7 +237,7 @@ class TestEmClassLinkType(ClassesTestCase):
237 237
     # should be able to select on the created table
238 238
     def test_table_classes_types(self):
239 239
         """ Test if a table 'testEntity_keywords' was created """
240
-        conn = sqlutils.getEngine().connect()
240
+        conn = sqlutils.get_engine().connect()
241 241
         a = sqlutils.meta(conn)
242 242
         try:
243 243
             newtable = sqla.Table('testEntity_keywords', sqlutils.meta(conn))

+ 2
- 2
EditorialModel/test/test_component.py View File

@@ -70,7 +70,7 @@ def setUpModule():
70 70
 
71 71
     sqlsetup.init_db('default', False, tables)   
72 72
 
73
-    dbe = sqlutils.getEngine('default')
73
+    dbe = sqlutils.get_engine('default')
74 74
 
75 75
     # Insertion of testings datas
76 76
     conn = dbe.connect()
@@ -135,7 +135,7 @@ class ComponentTestCase(TestCase):
135 135
         return globals()['tables']
136 136
     
137 137
     def setUp(self):
138
-        self.dber = sqlutils.getEngine('default')
138
+        self.dber = sqlutils.get_engine('default')
139 139
         self.test_values = self.__class__.test_values
140 140
         #Db RAZ
141 141
         #shutil.copyfile(TEST_COMPONENT_DBNAME+'_bck', globals()['component_test_dbfilename'])

+ 2
- 2
EditorialModel/test/test_fieldgroups.py View File

@@ -67,7 +67,7 @@ class TestInit(FieldGroupTestCase):
67 67
 
68 68
     def setUp(self):
69 69
         super(TestInit, self).setUp()
70
-        conn = sqlutils.getEngine().connect()
70
+        conn = sqlutils.get_engine().connect()
71 71
 
72 72
         ent1 = EmClass('entity1')
73 73
         idx1 = EmClass('entry1')
@@ -81,7 +81,7 @@ class TestInit(FieldGroupTestCase):
81 81
             { 'uid': EmFieldGroup.new_uid(), 'name': 'fg3', 'string': '{"fr":"Super Fieldgroup"}', 'help': '{"en":"help"}', 'rank': 2 , 'class_id': idx1.uid, 'date_create': self.creadate, 'date_update': self.creadate},
82 82
         ]
83 83
 
84
-        req = sqla.Table('em_fieldgroup', sqlutils.meta(sqlutils.getEngine())).insert(self.tfg)
84
+        req = sqla.Table('em_fieldgroup', sqlutils.meta(sqlutils.get_engine())).insert(self.tfg)
85 85
         conn.execute(req)
86 86
         conn.close()
87 87
         pass

Loading…
Cancel
Save