Bladeren bron

Fixing the code because of DataSources changes

Yann Weber 9 jaren geleden
bovenliggende
commit
14b5bd0fdb

+ 2
- 1
EditorialModel/fields.py Bestand weergeven

@@ -57,9 +57,10 @@ class EmField(EmComponent):
57 57
         self._fieldtype_args = kwargs
58 58
         self._fieldtype_args.update({'nullable': nullable, 'uniq': uniq, 'internal': self.internal})
59 59
         self.set_fieldtype_options(**self._fieldtype_args)
60
+        fieldtype_instance = self._fieldtype_cls(**self._fieldtype_args)
60 61
 
61 62
         if 'default' in kwargs:
62
-            if not fieldtype_instance.check(default):
63
+            if not fieldtype_instance.check_data_value(kwargs['default']):
63 64
                 raise TypeError("Default value ('%s') is not valid given the fieldtype '%s'" % (default, fieldtype))
64 65
 
65 66
         super(EmField, self).__init__(model=model, uid=uid, name=name, string=string, help_text=help_text, date_update=date_update, date_create=date_create, rank=rank)

+ 3
- 3
EditorialModel/model.py Bestand weergeven

@@ -4,7 +4,7 @@
4 4
 # Contains the class managing and editorial model
5 5
 
6 6
 import EditorialModel
7
-from DataSource.dummy.migrationhandler import DummyMigrationHandler
7
+from DataSource.dummy.migrationhandler import MigrationHandler
8 8
 from EditorialModel.backend.dummy_backend import EmBackendDummy
9 9
 from EditorialModel.classes import EmClass
10 10
 from EditorialModel.fields import EmField
@@ -24,8 +24,8 @@ class Model(object):
24 24
     # @param migration_handler : A migration handler
25 25
     def __init__(self, backend, migration_handler=None):
26 26
         if migration_handler is None:
27
-            self.migration_handler = DummyMigrationHandler()
28
-        elif issubclass(migration_handler.__class__, DummyMigrationHandler):
27
+            self.migration_handler = MigrationHandler()
28
+        elif issubclass(migration_handler.__class__, MigrationHandler):
29 29
             self.migration_handler = migration_handler
30 30
         else:
31 31
             raise TypeError("migration_handler should be an instance from a subclass of DummyMigrationhandler")

+ 2
- 2
EditorialModel/test/test_classes.py Bestand weergeven

@@ -15,7 +15,7 @@ from EditorialModel.types import EmType
15 15
 from EditorialModel.fields import EmField
16 16
 from EditorialModel.model import Model
17 17
 from EditorialModel.backend.json_backend import EmBackendJson
18
-from DataSource.dummy.migrationhandler import DummyMigrationHandler
18
+from DataSource.dummy.migrationhandler import MigrationHandler
19 19
 
20 20
 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Lodel.settings")
21 21
 EM_TEST = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'me.json')
@@ -26,7 +26,7 @@ EM_TEST_OBJECT = None
26 26
 def setUpModule():
27 27
     global EM_TEST_OBJECT
28 28
     #EM_TEST_OBJECT = Model(EmBackendJson(EM_TEST), migration_handler=DjandoMigrationHandler('LodelTestInstance'))
29
-    EM_TEST_OBJECT = Model(EmBackendJson(EM_TEST), migration_handler=DummyMigrationHandler())
29
+    EM_TEST_OBJECT = Model(EmBackendJson(EM_TEST), migration_handler=MigrationHandler())
30 30
     logging.basicConfig(level=logging.CRITICAL)
31 31
 
32 32
 

+ 2
- 2
EditorialModel/test/test_component.py Bestand weergeven

@@ -9,7 +9,7 @@ from EditorialModel.fields import EmField
9 9
 from Lodel.utils.mlstring import MlString
10 10
 
11 11
 from EditorialModel.backend.json_backend import EmBackendJson
12
-from DataSource.dummy.migrationhandler import DummyMigrationHandler
12
+from DataSource.dummy.migrationhandler import MigrationHandler
13 13
 
14 14
 
15 15
 class TestEmComponent(unittest.TestCase):
@@ -19,7 +19,7 @@ class TestEmComponent(unittest.TestCase):
19 19
     def test_hashes(self):
20 20
         """ Testing __hash__ and __eq__ methods """
21 21
         me1 = Model(EmBackendJson('EditorialModel/test/me.json'))
22
-        me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DummyMigrationHandler())
22
+        me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=MigrationHandler())
23 23
 
24 24
         for comp_class in [EmClass, EmType, EmField]:
25 25
             comp_l1 = me1.components(comp_class)

+ 2
- 0
EditorialModel/test/test_field.py Bestand weergeven

@@ -1,5 +1,6 @@
1 1
 import os
2 2
 
3
+import unittest
3 4
 from unittest import TestCase
4 5
 from EditorialModel.fields import EmField
5 6
 from EditorialModel.model import Model
@@ -63,6 +64,7 @@ class TestField(FieldTestCase):
63 64
         with self.assertRaises(ValueError, msg="Only common_fields should be internal='object'"):
64 65
             field = EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'testbadinternal','internal': 'object', 'class_id': self.test_class.uid, 'fieldtype': self.test_fieldtype})
65 66
 
67
+    @unittest.skip("rel2type are not uniq like this anymore")
66 68
     def test_double_rel2type(self):
67 69
         """ Test the rel2type unicity """
68 70
         em = EM_TEST_OBJECT

+ 9
- 9
EditorialModel/test/test_model.py Bestand weergeven

@@ -11,7 +11,7 @@ from Lodel.utils.mlstring import MlString
11 11
 
12 12
 from EditorialModel.backend.json_backend import EmBackendJson
13 13
 from EditorialModel.backend.dummy_backend import EmBackendDummy
14
-from DataSource.dummy.migrationhandler import DummyMigrationHandler
14
+from DataSource.dummy.migrationhandler import MigrationHandler
15 15
 
16 16
 
17 17
 class TestModel(unittest.TestCase):
@@ -24,15 +24,15 @@ class TestModel(unittest.TestCase):
24 24
         model = Model(EmBackendJson('EditorialModel/test/me.json'))
25 25
         self.assertTrue(isinstance(model, Model))
26 26
 
27
-        model = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DummyMigrationHandler())
27
+        model = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=MigrationHandler())
28 28
         self.assertTrue(isinstance(model, Model))
29 29
 
30 30
     def test_bad_init(self):
31 31
         """ Test initialisation with bad arguments """
32
-        for bad in [None, int, EmBackendDummy, DummyMigrationHandler, 'foobar']:
32
+        for bad in [None, int, EmBackendDummy, MigrationHandler, 'foobar']:
33 33
             with self.assertRaises(TypeError, msg="Tried to instanciate a Model with a bad backend"):
34 34
                 Model(bad)
35
-        for bad in [int, EmBackendDummy, DummyMigrationHandler, 'foobar']:
35
+        for bad in [int, EmBackendDummy, MigrationHandler, 'foobar']:
36 36
             with self.assertRaises(TypeError, msg="Tried to instanciate a Model with a migration_handler"):
37 37
                 Model(EmBackendDummy(), bad)
38 38
 
@@ -246,8 +246,8 @@ class TestModel(unittest.TestCase):
246 246
             for nat, sup_l in emtype.superiors().items():
247 247
                 superiors_list_orig[nat] = [sup.uid for sup in sup_l]
248 248
 
249
-        with patch.object(DummyMigrationHandler, 'register_change', return_value=None) as mh_mock:
250
-            self.ed_mod.migrate_handler(DummyMigrationHandler())
249
+        with patch.object(MigrationHandler, 'register_change', return_value=None) as mh_mock:
250
+            self.ed_mod.migrate_handler(MigrationHandler())
251 251
             #Getting cloned EM instance
252 252
             new_me = mh_mock.mock_calls[-1][1][0]
253 253
             for emtype in new_me.components(EmType):
@@ -269,8 +269,8 @@ class TestModel(unittest.TestCase):
269 269
 
270 270
     def test_migrate_handler_hashes(self):
271 271
         """ Testing that the migrate_handler() method create an EM with the same hash as the original EM """
272
-        with patch.object(DummyMigrationHandler, 'register_change', return_value=None) as mh_mock:
273
-            self.ed_mod.migrate_handler(DummyMigrationHandler())
272
+        with patch.object(MigrationHandler, 'register_change', return_value=None) as mh_mock:
273
+            self.ed_mod.migrate_handler(MigrationHandler())
274 274
             #Getting the cloned EM instance
275 275
             last_call = mh_mock.mock_calls[-1]
276 276
             self.assertEqual(hash(last_call[1][0]), hash(self.ed_mod))
@@ -278,7 +278,7 @@ class TestModel(unittest.TestCase):
278 278
     def test_hash(self):
279 279
         """ Test that __hash__ and __eq__ work properly on models """
280 280
         me1 = Model(EmBackendJson('EditorialModel/test/me.json'))
281
-        me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DummyMigrationHandler())
281
+        me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=MigrationHandler())
282 282
 
283 283
         self.assertEqual(hash(me1), hash(me2), "When instanciate from the same backend & file but with another migration handler the hashes differs")
284 284
         self.assertTrue(me1.__eq__(me2))

+ 1
- 1
install/utils.py Bestand weergeven

@@ -88,4 +88,4 @@ def dir_init():
88 88
             os.unlink(my_file_path)
89 89
         with open(my_file_path, 'w') as my_file:
90 90
             my_file.write(template['content'])
91
-        print("Created %s" % my_file_path)
91
+        print("Created %s" % my_file_path)

+ 27
- 1
leapi/lecrud.py Bestand weergeven

@@ -10,6 +10,7 @@ import importlib
10 10
 import re
11 11
 
12 12
 from Lodel import logger
13
+from Lodel.settings import Settings
13 14
 from EditorialModel.fieldtypes.generic import DatasConstructor
14 15
 from Lodel.hooks import LodelHook
15 16
 
@@ -44,9 +45,29 @@ class LeApiQueryError(LeApiErrors): pass
44 45
 ## @brief When an error concerns a datas
45 46
 class LeApiDataCheckError(LeApiErrors): pass
46 47
     
48
+class _MetaLeCrud(type):
49
+     def __getattribute__(self, name):
50
+        if name == '_datasource':
51
+            if super().__getattribute__('_datasource') is None:
52
+                module = importlib.import_module("DataSource.{pkg_name}.leapidatasource".format(
53
+                    pkg_name = Settings.ds_package,
54
+                    mod_name = 'leapidatasource'
55
+                ))
56
+                ds_cls = getattr(module, 'LeapiDataSource')
57
+                super().__setattr__('_datasource', ds_cls(**Settings.datasource_options))
58
+        return super().__getattribute__(name)
59
+
60
+
61
+        if 'leapidatasource' in globals():
62
+            if name == '_datasource' and isinstance(self._datasource, DummyDatasource):
63
+                #if name == '_datasource' and self._datasource == None:
64
+                leapids = globals()['leapidatasource']
65
+                if not isinstance(leapids, DummyDatasource):
66
+                    self._datasource = leapids({})
67
+        return super().__getattribute__(name)
47 68
 
48 69
 ## @brief Main class to handler lodel editorial components (relations and objects)
49
-class _LeCrud(object):
70
+class _LeCrud(object, metaclass = _MetaLeCrud):
50 71
     ## @brief The datasource
51 72
     _datasource = None
52 73
 
@@ -102,6 +123,11 @@ class _LeCrud(object):
102 123
         ## @brief A flag to indicate if the object was fully intanciated or not
103 124
         self._instanciation_complete = len(kwargs) + 1 == len(self.fieldlist())
104 125
 
126
+    def __getattribute__(self, name):
127
+        if name == '_datasource':
128
+            return _MetaLeCrud.__getattribute__(self.__class__, name)
129
+        return super().__getattribute__(name)
130
+
105 131
     ## @brief Convert an EmType or EmClass name in a python class name
106 132
     # @param name str : The name
107 133
     # @return name.title()

+ 3
- 11
leapi/lefactory.py Bestand weergeven

@@ -38,9 +38,9 @@ class LeFactory(object):
38 38
     
39 39
     ## @brief Write generated code to a file
40 40
     # @todo better options/params for file creation
41
-    def create_pyfile(self, model, datasource_cls, datasource_args):
41
+    def create_pyfile(self, model):
42 42
         with open(self._code_filename, "w+") as dynfp:
43
-            dynfp.write(self.generate_python(model, datasource_cls, datasource_args))
43
+            dynfp.write(self.generate_python(model))
44 44
 
45 45
     ## @brief Generate fieldtypes for concret classes
46 46
     # @param ft_dict dict : key = fieldname value = fieldtype __init__ args
@@ -176,7 +176,7 @@ class {classname}(LeRel2Type):
176 176
     # @param datasource_cls Datasource : A datasource class
177 177
     # @param datasource_args dict : A dict representing arguments for datasource_cls instanciation
178 178
     # @return A string representing python code
179
-    def generate_python(self, model, datasource_cls, datasource_args):
179
+    def generate_python(self, model):
180 180
         self.needed_fieldtypes = set() #Stores the list of fieldtypes that will be used by generated code
181 181
 
182 182
         model = model
@@ -199,11 +199,6 @@ from leapi.leclass import _LeClass
199 199
 from leapi.letype import _LeType
200 200
 """
201 201
 
202
-        result += """
203
-import %s
204
-
205
-""" % (datasource_cls.__module__)
206
-
207 202
         #Generating the code for LeObject class
208 203
         leobj_me_uid = dict()
209 204
         for comp in model.components('EmType') + model.components('EmClass'):
@@ -224,7 +219,6 @@ import %s
224 219
 ## @brief _LeCrud concret class
225 220
 # @see leapi.lecrud._LeCrud
226 221
 class LeCrud(leapi.lecrud._LeCrud):
227
-    _datasource = {ds_classname}(**{ds_kwargs})
228 222
     _uid_fieldtype = None
229 223
 
230 224
 ## @brief _LeObject concret class
@@ -257,8 +251,6 @@ class LeClass(LeObject, _LeClass):
257 251
 class LeType(LeClass, _LeType):
258 252
     pass
259 253
 """.format(
260
-            ds_classname = datasource_cls.__module__ + '.' + datasource_cls.__name__,
261
-            ds_kwargs = repr(datasource_args),
262 254
             me_uid_l = repr(leobj_me_uid),
263 255
             leo_uid_fieldtype = leobj_uid_fieldtype,
264 256
             leo_fieldtypes = '{\n\t' + (',\n\t'.join(leobj_fieldtypes))+ '\n\t}',

+ 5
- 5
leapi/test/test_lecrud.py Bestand weergeven

@@ -179,7 +179,7 @@ class LeCrudTestCase(TestCase):
179 179
     #   Tests mocking the datasource
180 180
181 181
 
182
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.insert')
182
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.insert')
183 183
     def test_insert(self, dsmock):
184 184
         from dyncode import Publication, Numero, LeObject, Personne, Article
185 185
         ndatas = [
@@ -205,7 +205,7 @@ class LeCrudTestCase(TestCase):
205 205
             dsmock.reset_mock()
206 206
     
207 207
     ## @todo try failing on inserting from LeClass child or LeObject
208
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.insert')
208
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.insert')
209 209
     def test_insert_fails(self, dsmock):
210 210
         from dyncode import Publication, Numero, LeObject, Personne, Article
211 211
         ndatas = [
@@ -221,7 +221,7 @@ class LeCrudTestCase(TestCase):
221 221
                 assert not dsmock.called
222 222
         pass
223 223
     
224
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.update')
224
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.update')
225 225
     def test_update(self, dsmock):
226 226
         from dyncode import Publication, Numero, LeObject
227 227
         
@@ -242,7 +242,7 @@ class LeCrudTestCase(TestCase):
242 242
             dsmock.assert_called_once_with(ccls, eid, **qdatas)
243 243
     
244 244
     ## @todo test invalid get
245
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.select')
245
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.select')
246 246
     def test_get(self, dsmock):
247 247
         """ Test the select method without group, limit, sort or offset """
248 248
         from dyncode import Publication, Numero, LeObject, Textes
@@ -321,7 +321,7 @@ class LeCrudTestCase(TestCase):
321 321
                                     )
322 322
             dsmock.reset_mock()
323 323
     
324
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.select')
324
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.select')
325 325
     def test_get_complete(self, dsmock):
326 326
         """ Test the select method with group limit sort and offset arguments """
327 327
         from dyncode import Numero

+ 3
- 3
leapi/test/test_leobject.py Bestand weergeven

@@ -58,7 +58,7 @@ class LeObjectMockDatasourceTestCase(TestCase):
58 58
         """ Remove the temporary directory created at class setup """
59 59
         leapi.test.utils.cleanup(cls.tmpdir)
60 60
     
61
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.insert')
61
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.insert')
62 62
     def test_insert(self, dsmock):
63 63
         from dyncode import Publication, Numero, LeObject
64 64
         ndatas = [
@@ -81,7 +81,7 @@ class LeObjectMockDatasourceTestCase(TestCase):
81 81
             dsmock.assert_called_once_with(Numero, **expt_dats)
82 82
             dsmock.reset_mock()
83 83
 
84
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.update')
84
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.update')
85 85
     def test_update(self, dsmock):
86 86
         from dyncode import Publication, Numero, LeObject, Personne, Article, RelTextesPersonneAuteur
87 87
 
@@ -98,7 +98,7 @@ class LeObjectMockDatasourceTestCase(TestCase):
98 98
                 dsmock.assert_called_once_with(instance.__class__, instance.uidget(), **datas)
99 99
                 dsmock.reset_mock()
100 100
     
101
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.delete')
101
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.delete')
102 102
     def test_delete(self, dsmock):
103 103
         from dyncode import Publication, Numero, LeObject, LeType, LeRelation
104 104
         

+ 7
- 7
leapi/test/test_lerelation.py Bestand weergeven

@@ -69,7 +69,7 @@ class LeRelationTestCase(TestCase):
69 69
             for i in range(3):
70 70
                 self.assertEqual(filter_res[i], res[i], "%s != %s"%(filter_res, res))
71 71
 
72
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.delete')
72
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.delete')
73 73
     def test_delete(self, dsmock):
74 74
         """ Testing LeHierarch insert method """
75 75
         from dyncode import LeCrud, Publication, Numero, Personnes, LeObject, Rubrique, LeHierarch, LeRelation
@@ -81,7 +81,7 @@ class LeRelationTestCase(TestCase):
81 81
 
82 82
 class LeHierarch(LeRelationTestCase):
83 83
     
84
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.select')
84
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.select')
85 85
     def test_get(self, dsmock):
86 86
         """ Tests the LeHierarch.get() method without limit group order etc."""
87 87
         from dyncode import LeCrud, Publication, Numero, Personnes, LeObject, Rubrique, LeHierarch, LeRelation
@@ -123,7 +123,7 @@ class LeHierarch(LeRelationTestCase):
123 123
 
124 124
             dsmock.reset_mock()
125 125
     
126
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.insert')
126
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.insert')
127 127
     def test_insert(self, dsmock):
128 128
         """ Testing LeHierarch insert method """
129 129
         from dyncode import LeCrud, Publication, Numero, Personnes, LeObject, Rubrique, LeHierarch, LeRelation
@@ -194,7 +194,7 @@ class LeHierarch(LeRelationTestCase):
194 194
             dsmock.reset_mock()
195 195
     
196 196
 
197
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.delete')
197
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.delete')
198 198
     def test_delete(self, dsmock):
199 199
         """ Testing LeHierarch delete method """
200 200
         from dyncode import LeCrud, Publication, Numero, Personnes, LeObject, Rubrique, LeHierarch, LeRelation
@@ -203,7 +203,7 @@ class LeHierarch(LeRelationTestCase):
203 203
         dsmock.assert_called_once_with(LeHierarch, 10)
204 204
         
205 205
     
206
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.update')
206
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.update')
207 207
     def test_update(self, dsmock):
208 208
         """ test LeHierach update method"""
209 209
         from dyncode import LeHierarch
@@ -214,7 +214,7 @@ class LeHierarch(LeRelationTestCase):
214 214
 
215 215
 class LeRel2TypeTestCase(LeRelationTestCase):
216 216
     
217
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.insert')
217
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.insert')
218 218
     def test_insert(self, dsmock):
219 219
         """ test LeHierach update method"""
220 220
         from dyncode import LeObject, Article, Textes, Personne, Personnes, LeHierarch, LeRel2Type, RelTextesPersonneAuteur
@@ -265,7 +265,7 @@ class LeRel2TypeTestCase(LeRelationTestCase):
265 265
             dsmock.assert_called_once_with(RelTextesPersonneAuteur, **eres)
266 266
             dsmock.reset_mock()
267 267
 
268
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.insert')
268
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.insert')
269 269
     def test_insert_fails(self, dsmock):
270 270
         """ test LeHierach update method"""
271 271
         from dyncode import LeObject, Rubrique, Numero, Article, Textes, Personne, Personnes, LeHierarch, LeRel2Type, RelTextesPersonneAuteur

+ 3
- 3
leapi/test/test_letype.py Bestand weergeven

@@ -102,7 +102,7 @@ class LeTypeMockDsTestCase(TestCase):
102 102
         """ Remove the temporary directory created at class setup """
103 103
         leapi.test.utils.cleanup(cls.tmpdir)
104 104
 
105
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.select')
105
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.select')
106 106
     def test_populate(self, dsmock):
107 107
         from dyncode import Publication, Numero, LeObject
108 108
 
@@ -112,7 +112,7 @@ class LeTypeMockDsTestCase(TestCase):
112 112
             num.populate()
113 113
             dsmock.assert_called_once_with(Numero, missing_fields, [('lodel_id','=',1)],[])
114 114
 
115
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.update')
115
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.update')
116 116
     def test_update(self, dsmock):
117 117
         from dyncode import Publication, Numero, LeObject
118 118
         
@@ -125,7 +125,7 @@ class LeTypeMockDsTestCase(TestCase):
125 125
             mock_populate.assert_called_once_with()
126 126
             dsmock.assert_called_once_with(Numero, num.uidget(), **datas)
127 127
     
128
-    @patch('DataSource.dummy.leapidatasource.DummyDatasource.delete')
128
+    @patch('DataSource.dummy.leapidatasource.LeapiDataSource.delete')
129 129
     def test_delete(self, dsmock):
130 130
         from dyncode import Publication, Numero, LeObject
131 131
         

+ 1
- 3
leapi/test/utils.py Bestand weergeven

@@ -5,15 +5,13 @@ import sys
5 5
 from EditorialModel.model import Model
6 6
 import leapi
7 7
 from EditorialModel.backend.json_backend import EmBackendJson
8
-from DataSource.MySQL.leapidatasource import DummyDatasource
8
+from DataSource.dummy.leapidatasource import LeapiDataSource
9 9
 from leapi.lefactory import LeFactory
10 10
 
11 11
 
12 12
 
13 13
 genepy_args = {
14 14
     'model' : Model(EmBackendJson(json_file = 'EditorialModel/test/me.json')),
15
-    'datasource_cls': DummyDatasource,
16
-    'datasource_args': {}
17 15
 }
18 16
 
19 17
 def tmp_load_factory_code(name='dyncode'):

+ 2
- 3
refreshdyn.py Bestand weergeven

@@ -6,7 +6,6 @@ import sys
6 6
 from EditorialModel.model import Model
7 7
 from leapi.lefactory import LeFactory
8 8
 from EditorialModel.backend.json_backend import EmBackendJson
9
-from DataSource.MySQL.leapidatasource import LeDataSourceSQL
10 9
 
11 10
 OUTPUT = 'leapi/dyn.py' if len(sys.argv) == 1 else sys.argv[1]
12 11
 EMJSON = 'EditorialModel/test/me.json' if len(sys.argv) < 3 else sys.argv[2]
@@ -14,7 +13,7 @@ EMJSON = 'EditorialModel/test/me.json' if len(sys.argv) < 3 else sys.argv[2]
14 13
 em = Model(EmBackendJson(EMJSON))
15 14
 
16 15
 fact = LeFactory(OUTPUT)
17
-fact.create_pyfile(em, LeDataSourceSQL, {})
18
-print(fact.generate_python(em, LeDataSourceSQL, {}))
16
+fact.create_pyfile(em)
17
+print(fact.generate_python(em))
19 18
 
20 19
 

Loading…
Annuleren
Opslaan