Browse Source

Move and skip some tests

Yann Weber 9 years ago
parent
commit
4fedabcf88
3 changed files with 6 additions and 63 deletions
  1. 1
    0
      leapi/leobject.py
  2. 2
    62
      leapi/test/test_leobject.py
  3. 3
    1
      leapi/test/test_letype.py

+ 1
- 0
leapi/leobject.py View File

316
     # @todo Delete the checks of letype and leclass and ensure that this method is called with letype and leclass arguments from _prepare_targets()
316
     # @todo Delete the checks of letype and leclass and ensure that this method is called with letype and leclass arguments from _prepare_targets()
317
     #
317
     #
318
     # @see @ref leobject_filters
318
     # @see @ref leobject_filters
319
+    # @todo delete me
319
     @staticmethod
320
     @staticmethod
320
     def _check_fields(letype, leclass, fields):
321
     def _check_fields(letype, leclass, fields):
321
         warnings.warn("deprecated", DeprecationWarning)
322
         warnings.warn("deprecated", DeprecationWarning)

+ 2
- 62
leapi/test/test_leobject.py View File

23
         """ Remove the temporary directory created at class setup """
23
         """ Remove the temporary directory created at class setup """
24
         leapi.test.utils.cleanup(cls.tmpdir)
24
         leapi.test.utils.cleanup(cls.tmpdir)
25
 
25
 
26
-    def test_split_query_filter(self):
27
-        """ Tests the _split_filter() classmethod """
28
-        import dyncode
29
-        query_results = {
30
-            'Hello = world' : ('Hello', '=', 'world'),
31
-            'hello <= "world"': ('hello', '<=', '"world"'),
32
-            '_he42_ll-o >= \'world"': ('_he42_ll-o', '>=', '\'world"'),
33
-            'foo in ["foo", 42, \'bar\']': ('foo', ' in ', '["foo", 42, \'bar\']'),
34
-            ' bar42              < 42': ('bar42', '<', '42'),
35
-            ' _hidden > 1337': ('_hidden', '>', '1337'),
36
-            '_42 not in foobar': ('_42', ' not in ', 'foobar'),
37
-            'hello                       in      foo':('hello', ' in ', 'foo'),
38
-            "\t\t\thello\t\t\nin\nfoo\t\t\n\t":('hello', ' in ', 'foo'),
39
-            "hello \nnot\tin \nfoo":('hello', ' not in ', 'foo'),
40
-            'hello != bar':('hello', '!=', 'bar'),
41
-            'hello = "world>= <= != in not in"': ('hello', '=', '"world>= <= != in not in"'),
42
-            'superior.parent = 13': ('superior.parent', '=', '13'),
43
-        }
44
-        for query, result in query_results.items():
45
-            res = dyncode.LeObject._split_filter(query)
46
-            self.assertEqual(res, result, "When parsing the query : '%s' the returned value is different from the expected '%s'"%(query, result))
47
-
48
-    def test_invalid_split_query_filter(self):
49
-        """ Testing the _split_filter() method with invalid queries """
50
-        import dyncode
51
-        invalid_queries = [
52
-            '42 = 42',
53
-            '4hello = foo',
54
-            'foo == bar',
55
-            'hello >> world',
56
-            'hello =    ',
57
-            ' = world',
58
-            '=',
59
-            '42',
60
-            '"hello" = world',
61
-            'foo.bar = 15',
62
-        ]
63
-        for query in invalid_queries:
64
-            with self.assertRaises(ValueError, msg='But the query was not valid : "%s"'%query):
65
-                dyncode.LeObject._split_filter(query)
66
-
67
     def test_uid2leobj(self):
26
     def test_uid2leobj(self):
68
         """ Testing _Leobject.uid2leobj() """
27
         """ Testing _Leobject.uid2leobj() """
69
         import dyncode
28
         import dyncode
104
         for (leclass, letype), (rleclass, rletype) in test_v.items():
63
         for (leclass, letype), (rleclass, rletype) in test_v.items():
105
             self.assertEqual((rletype,rleclass), LeObject._prepare_targets(letype, leclass))
64
             self.assertEqual((rletype,rleclass), LeObject._prepare_targets(letype, leclass))
106
 
65
 
66
+    @unittest.skip("Obsolete but may be usefull for datasources tests")
107
     def test_invalid_prepare_targets(self):
67
     def test_invalid_prepare_targets(self):
108
         """ Testing _prepare_targets() method with invalid arguments """
68
         """ Testing _prepare_targets() method with invalid arguments """
109
         from dyncode import Publication, Numero, LeObject, Personnes
69
         from dyncode import Publication, Numero, LeObject, Personnes
129
         for (leclass, letype) in test_v:
89
         for (leclass, letype) in test_v:
130
             with self.assertRaises(ValueError):
90
             with self.assertRaises(ValueError):
131
                 LeObject._prepare_targets(letype, leclass)
91
                 LeObject._prepare_targets(letype, leclass)
132
-
92
+    @unittest.skip("Obsolete, the method should be deleted soon")
133
     def test_check_fields(self):
93
     def test_check_fields(self):
134
         """ Testing the _check_fields() method """
94
         """ Testing the _check_fields() method """
135
         from dyncode import Publication, Numero, LeObject, Personnes
95
         from dyncode import Publication, Numero, LeObject, Personnes
148
             LeObject._check_fields(None, None, Numero._fields)
108
             LeObject._check_fields(None, None, Numero._fields)
149
 
109
 
150
 
110
 
151
-    def test_prepare_filters_invalid(self):
152
-        """ Testing the _prepare_filters() method """
153
-        from dyncode import Publication, Numero, LeObject, Personnes
154
-
155
-        #Numero fields filters but no letype nor leclass given
156
-        filters = []
157
-        res_filt = []
158
-        for field in Numero._fields:
159
-            filters.append('%s=1'%field)
160
-            res_filt.append((field, '=', '1'))
161
-        
162
-        with self.assertRaises(leapi.lecrud.LeApiDataCheckError):
163
-            LeObject._prepare_filters(filters)
164
-
165
-
166
-        #simply invalid filters
167
-        filters = ['hello world !']
168
-        with self.assertRaises(ValueError):
169
-            LeObject._prepare_filters(filters)
170
-
171
 class LeObjectMockDatasourceTestCase(TestCase):
111
 class LeObjectMockDatasourceTestCase(TestCase):
172
     """ Testing _LeObject using a mock on the datasource """
112
     """ Testing _LeObject using a mock on the datasource """
173
 
113
 

+ 3
- 1
leapi/test/test_letype.py View File

20
     def tearDownClass(cls):
20
     def tearDownClass(cls):
21
         """ Remove the temporary directory created at class setup """
21
         """ Remove the temporary directory created at class setup """
22
         leapi.test.utils.cleanup(cls.tmpdir)
22
         leapi.test.utils.cleanup(cls.tmpdir)
23
- 
23
+
24
+    @unittest.skip("Waiting for EmFieldType full implementation")
24
     def test_init(self):
25
     def test_init(self):
25
         """ testing the constructor """
26
         """ testing the constructor """
26
         from dyncode import Publication, Numero, LeObject
27
         from dyncode import Publication, Numero, LeObject
45
                 Numero(**badarg)
46
                 Numero(**badarg)
46
     
47
     
47
     ## @todo when we will have a field in a type that has a check_function try to make check_datas_or_raise raise with invalid value
48
     ## @todo when we will have a field in a type that has a check_function try to make check_datas_or_raise raise with invalid value
49
+    @unittest.skip("Waiting for EmFieldType full implementation")
48
     def test_check_datas(self):
50
     def test_check_datas(self):
49
         """ testing the check_datas* methods """
51
         """ testing the check_datas* methods """
50
         from dyncode import Publication, Numero, LeObject
52
         from dyncode import Publication, Numero, LeObject

Loading…
Cancel
Save