skeleton/test/realdb_test_CUBENAME.py
changeset 11057 0b59724cb3f2
parent 11052 058bb3dc685f
child 11058 23eb30449fe5
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of CubicWeb.
       
     5 #
       
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License
       
    17 # along with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    18 """
       
    19 
       
    20 """
       
    21 from cubicweb.devtools.testlib import CubicWebTC
       
    22 from cubicweb.devtools.realdbtest import buildconfig, loadconfig
       
    23 
       
    24 
       
    25 def setUpModule(options):
       
    26     if options.source:
       
    27         configcls = loadconfig(options.source)
       
    28     elif options.dbname is None:
       
    29         raise Exception('either <sourcefile> or <dbname> options are required')
       
    30     else:
       
    31         configcls = buildconfig(options.dbuser, options.dbpassword,
       
    32                                 options.dbname,
       
    33                                 options.euser, options.epassword)
       
    34     RealDatabaseTC.configcls = configcls
       
    35 
       
    36 
       
    37 class RealDatabaseTC(CubicWebTC):
       
    38     configcls = None  # set by setUpModule()
       
    39 
       
    40     def test_all_primaries(self):
       
    41         for rset in self.iter_individual_rsets(limit=50):
       
    42             yield self.view, 'primary', rset, rset.req.reset_headers()
       
    43 
       
    44     ## startup views
       
    45     def test_startup_views(self):
       
    46         for vid in self.list_startup_views():
       
    47             req = self.request()
       
    48             yield self.view, vid, None, req
       
    49 
       
    50 
       
    51 if __name__ == '__main__':
       
    52     from logilab.common.testlib import unittest_main
       
    53     unittest_main()