skeleton/test/test_CUBENAME.py.tmpl
author Julien Cristau <julien.cristau@logilab.fr>
Wed, 22 Apr 2015 16:09:04 +0200
changeset 10894 c8c6ad8adbdb
parent 10214 88f60d4b9952
permissions -rw-r--r--
[server] install custom sql scripts before creating tables for the schema A cube might need something like 'CREATE EXTENSION postgis' before creating tables for its entities, to add new final types.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5915
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
     1
# copyright %(year)s %(author)s, all rights reserved.
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
     2
# contact %(author-web-site)s -- mailto:%(author-email)s
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
     3
#
5915
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
     4
%(long-license)s
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
     5
"""%(distname)s automatic tests
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
     6
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
     7
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
     8
uncomment code below if you want to activate automatic test for your cube:
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
     9
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    10
.. sourcecode:: python
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    11
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    12
    from cubicweb.devtools.testlib import AutomaticWebTest
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    13
5915
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    14
    class AutomaticWebTest(AutomaticWebTest):
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    15
        '''provides `to_test_etypes` and/or `list_startup_views` implementation
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    16
        to limit test scope
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    17
        '''
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    18
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    19
        def to_test_etypes(self):
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    20
            '''only test views for entities of the returned types'''
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    21
            return set(('My', 'Cube', 'Entity', 'Types'))
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    22
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    23
        def list_startup_views(self):
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    24
            '''only test startup views of the returned identifiers'''
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    25
            return ('some', 'startup', 'views')
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    26
"""
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
5915
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    28
from cubicweb.devtools import testlib
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
10214
88f60d4b9952 [newcube] Make the generated code PEP-8 compliant
Christophe de Vienne <christophe@unlish.com>
parents: 6898
diff changeset
    30
5915
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    31
class DefaultTC(testlib.CubicWebTC):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
    def test_something(self):
6898
60cbb2b39ca9 [skel] try to generate warning free stub...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5915
diff changeset
    33
        self.skipTest('this cube has no test')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
if __name__ == '__main__':
5915
e6cc50932720 [skel] nicer test file skeleton
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    37
    from logilab.common.testlib import unittest_main
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
    unittest_main()