test_array.py 2.11 KB
Newer Older
Vincent Michel's avatar
Vincent Michel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# copyright 2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr -- mailto:contact@logilab.fr
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 2.1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.

"""cubicweb-array automatic tests


uncomment code below if you want to activate automatic test for your cube:

.. sourcecode:: python

    from cubicweb.devtools.testlib import AutomaticWebTest

    class AutomaticWebTest(AutomaticWebTest):
        '''provides `to_test_etypes` and/or `list_startup_views` implementation
        to limit test scope
        '''

        def to_test_etypes(self):
            '''only test views for entities of the returned types'''
            return set(('My', 'Cube', 'Entity', 'Types'))

        def list_startup_views(self):
            '''only test startup views of the returned identifiers'''
            return ('some', 'startup', 'views')
"""

from cubicweb.devtools import testlib

class DefaultTC(testlib.CubicWebTC):
    def test_something(self):
44
45
46
47
48
49
50
51
52
53
54
55
        req = self.request()
        e = req.create_entity('EntityTypeWithArrays', iarray=range(5),
                              farray=[float(i) for i in range(5)])
        self.commit()

        req.drop_entity_cache()
        e.cw_clear_all_caches()

        self.assertTrue(isinstance(e.iarray, list))
        self.assertTrue(isinstance(e.farray, list))
        self.assertListEqual(e.iarray, range(5))
        self.assertListEqual(e.farray, [float(i) for i in range(5)])
Vincent Michel's avatar
Vincent Michel committed
56
57
58
59
60


if __name__ == '__main__':
    from logilab.common.testlib import unittest_main
    unittest_main()