source: indico/indicop/__init__.py @ a24134

burotelhello-world-walkthroughipv6v0.98-seriesv0.98.2v0.98.3v0.98b1v0.98b2v0.99v1.0v1.1
Last change on this file since a24134 was a24134, checked in by Pedro Ferreira <jose.pedro.ferreira@…>, 3 years ago

[NEW] Functional tests added to indicop

  • Property mode set to 100644
File size: 2.9 KB
Line 
1# -*- coding: utf-8 -*-
2##
3## $Id$
4##
5## This file is part of CDS Indico.
6## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
7##
8## CDS Indico is free software; you can redistribute it and/or
9## modify it under the terms of the GNU General Public License as
10## published by the Free Software Foundation; either version 2 of the
11## License, or (at your option) any later version.
12##
13## CDS Indico is distributed in the hope that it will be useful, but
14## WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16## General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with CDS Indico; if not, write to the Free Software Foundation, Inc.,
20## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21'''
22To add new tests simply create a new file inside tests/ or inside a subdir with a
23unittest.TestCase child class and this script will automatically find it.
24
25WARNING WARNING WARNING
26If you are launching tests inside Eclipse or any other IDE make sure that sys.path
27is properly set.
28'''
29import os
30import unittest
31import sys
32import glob
33import re
34import nose
35import figleaf
36import figleaf.annotate_html
37import subprocess
38
39
40def main(testPath, coverage):
41
42    print "Welcome in INDICOP"
43    sys.stdout.flush()
44    returnString=""
45   
46    if coverage:
47        figleaf.start()
48       
49    #Starting Selenium server
50    child = subprocess.Popen(["java", "-jar", "indicop/selenium_tests/selenium-server.jar"], stdout=subprocess.PIPE)
51   
52    #This is a cheap trick to make sure that selenium has fully
53    #started before launching the tests.
54    #Selenium (1.0.1) displays 5 lines in the shell before being ready
55    counter = 0
56    while counter < 5:
57        child_output = child.stdout.readline()
58        #print "Selenium debug %s: %s" % (counter, child_output)
59        counter += 1
60   
61    if testPath:
62        result = nose.run(argv=['nose','-v', 'indicop/MaKaC_tests/%s' % testPath])
63    else:
64        #result = nose.run(argv=['nose','-v', 'indicop/MaKaC_tests/'])
65        result = nose.run(argv=['nose','-v', 'indicop/selenium_tests/create_delete_lecture_test.py:Selenium_test.test_create_delete_lecture'])
66   
67    #Stopping Selenium Server
68    child.kill()
69   
70    if coverage:
71        figleaf.stop()
72        coverageOutput = figleaf.get_data().gather_files()
73        try:
74            figleaf.annotate_html.report_as_html(coverageOutput, 'indicop/coverage/html_report', [], {})
75        except Exception:
76            os.mkdir('indicop/coverage/html_report')
77            figleaf.annotate_html.report_as_html(coverageOutput, 'indicop/coverage/html_report', [], {})
78        returnString += "Report generated in indicop/coverage/html_report\n"
79   
80    if result:
81        returnString += "All tests succeeded!"
82    else:
83        returnString += "TestSuite failed!"
84   
85    return returnString
86
87if __name__ == '__main__':
88    main()
Note: See TracBrowser for help on using the repository browser.