Add some minimalistic tests

This commit is contained in:
Frédéric Péters 2011-03-04 11:46:41 +01:00
parent cb8120a150
commit dade38a5dd
2 changed files with 61 additions and 0 deletions

57
tests/__init__.py Normal file
View File

@ -0,0 +1,57 @@
# w.c.s. (asec) - w.c.s. extension for poll & survey service
# Copyright (C) 2011 Entr'ouvert
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
import sys
import os
import time
import twill
import ConfigParser
def setup():
CONFIG_FILE = os.getenv('ASEC_TESTS_CONFIGFILE')
if not CONFIG_FILE:
print >> sys.stderr, 'E: you should define ASEC_TESTS_CONFIGFILE'
sys.exit(1)
if not os.path.exists(CONFIG_FILE):
print >> sys.stderr, 'E: missing config file'
sys.exit(1)
global config
config = ConfigParser.ConfigParser()
config.readfp(file(CONFIG_FILE))
twill.set_output(file('/dev/null', 'w'))
def test_connection():
'''Check server is up'''
base_url = config.get('general', 'base_url')
twill.commands.reset_browser()
twill.execute_string('''
go %s
''' % base_url)
def test_asec_theme():
'''Check asec theme is configured'''
base_url = config.get('general', 'base_url')
twill.commands.reset_browser()
twill.execute_string('''
go %s
find /themes/asec/wcs.css
''' % base_url)

4
tests/sample.config Normal file
View File

@ -0,0 +1,4 @@
[general]
base_url = http://asec/
username = test@localhost
password = test