소스 검색

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

prieto 8 년 전
부모
커밋
754a5b7baa
6개의 변경된 파일35개의 추가작업 그리고 3개의 파일을 삭제
  1. 2
    0
      em_test.py
  2. BIN
      examples/em_test.pickle
  3. 4
    2
      lodel/leapi/query.py
  4. 4
    0
      plugins/mongodb_datasource/migration_handler.py
  5. BIN
      tests/editorial_model.pickle
  6. 25
    1
      tests/leapi/test_leobject.py

+ 2
- 0
em_test.py 파일 보기

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

BIN
examples/em_test.pickle 파일 보기


+ 4
- 2
lodel/leapi/query.py 파일 보기

@@ -23,8 +23,10 @@ class LeQuery(object):
23 23
         from .leobject import LeObject
24 24
         if self._hook_prefix is None:
25 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 30
         self._target_class = target_class
29 31
         self._ro_datasource = target_class._ro_datasource
30 32
         self._rw_datasource = target_class._rw_datasource

+ 4
- 0
plugins/mongodb_datasource/migration_handler.py 파일 보기

@@ -38,6 +38,10 @@ class MongoDbMigrationHandler(object):
38 38
         if len(conn_args.keys()) == 0:
39 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 45
         #self.connection_name = conn_args['name']
42 46
         self.database = connect(host=conn_args['host'], port=conn_args['port'], db_name=conn_args['db_name'],
43 47
                                 username=conn_args['username'], password=conn_args['password'])

BIN
tests/editorial_model.pickle 파일 보기


+ 25
- 1
tests/leapi/test_leobject.py 파일 보기

@@ -36,4 +36,28 @@ class LeFilteredQueryTestCase(unittest.TestCase):
36 36
         with self.assertRaises(LeApiErrors):
37 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…
취소
저장