Browse Source

Merge branch 'newlodel' of git.labocleo.org:lodel2 into newlodel

prieto 8 years ago
parent
commit
754a5b7baa

+ 2
- 0
em_test.py View File

45
                         group = base_group,
45
                         group = base_group,
46
                         data_handler = 'datetime',
46
                         data_handler = 'datetime',
47
                         now_on_create = True,
47
                         now_on_create = True,
48
+                        internal = True,
48
 )
49
 )
49
 em_object.new_field(    'date_update',
50
 em_object.new_field(    'date_update',
50
                         display_name = 'Last update',
51
                         display_name = 'Last update',
51
                         group = base_group,
52
                         group = base_group,
52
                         data_handler = 'datetime',
53
                         data_handler = 'datetime',
53
                         now_on_update = True,
54
                         now_on_update = True,
55
+                        internal = True,
54
 )
56
 )
55
 
57
 
56
 ########################
58
 ########################

BIN
examples/em_test.pickle View File


+ 4
- 2
lodel/leapi/query.py View File

23
         from .leobject import LeObject
23
         from .leobject import LeObject
24
         if self._hook_prefix is None:
24
         if self._hook_prefix is None:
25
             raise NotImplementedError("Abstract class")
25
             raise NotImplementedError("Abstract class")
26
-        if not issubclass(target_class, LeObject):
27
-            raise TypeError("target class has to be a child class of LeObject")
26
+        if not inspect.isclass(target_class) or \
27
+            not issubclass(target_class, LeObject):
28
+            raise TypeError("target class has to be a child class of LeObject \
29
+but %s given"% target_class)
28
         self._target_class = target_class
30
         self._target_class = target_class
29
         self._ro_datasource = target_class._ro_datasource
31
         self._ro_datasource = target_class._ro_datasource
30
         self._rw_datasource = target_class._rw_datasource
32
         self._rw_datasource = target_class._rw_datasource

+ 4
- 0
plugins/mongodb_datasource/migration_handler.py View File

38
         if len(conn_args.keys()) == 0:
38
         if len(conn_args.keys()) == 0:
39
             raise MigrationHandlerError("No connection arguments were given")
39
             raise MigrationHandlerError("No connection arguments were given")
40
 
40
 
41
+        if 'host' not in conn_args.keys() or 'port' not in conn_args.keys() or 'db_name' not in conn_args.keys() \
42
+            or 'username' not in conn_args.keys() or 'password' not in conn_args.keys():
43
+            raise MigrationHandlerError("Missing connection arguments")
44
+
41
         #self.connection_name = conn_args['name']
45
         #self.connection_name = conn_args['name']
42
         self.database = connect(host=conn_args['host'], port=conn_args['port'], db_name=conn_args['db_name'],
46
         self.database = connect(host=conn_args['host'], port=conn_args['port'], db_name=conn_args['db_name'],
43
                                 username=conn_args['username'], password=conn_args['password'])
47
                                 username=conn_args['username'], password=conn_args['password'])

BIN
tests/editorial_model.pickle View File


+ 25
- 1
tests/leapi/test_leobject.py View File

36
         with self.assertRaises(LeApiErrors):
36
         with self.assertRaises(LeApiErrors):
37
             dyncode.Person(lastname = "foo", firstname = "bar")
37
             dyncode.Person(lastname = "foo", firstname = "bar")
38
 
38
 
39
-        
39
+    
40
+    def test_initilized(self):
41
+        """ Testing initialized method """
42
+        inst = dyncode.Person(
43
+            lodel_id = 1, lastname="foo")
44
+        self.assertFalse(inst.initialized)
45
+
46
+    def test_uid_fieldname(self):
47
+        self.assertEqual(dyncode.Person.uid_fieldname(), ["lodel_id"])
48
+
49
+    def test_fieldnames_accessor(self):
50
+        """ Testing fieldnames() accessor method """
51
+        fnames = dyncode.Person.fieldnames(False)
52
+        self.assertEqual(set(fnames),
53
+            {'lastname', 'linked_texts', 'firstname', 'alias'})
54
+
55
+    def test_insert(self):
56
+        dyncode.Person.insert({'lastname': 'foo', 'firstname': 'bar'})
57
+    
58
+    @unittest.skip("wait")
59
+    def test_bad_insert(self):
60
+        """ Insert with bad arguments """
61
+        dyncode.Person.insert({})
62
+        dyncode.Person.insert({'lodel_id': 1,'lastname': 'foo', 'firstname': 'bar'})
63
+

Loading…
Cancel
Save