From e5c5a3778ede8b75a1cebf3f2f96ba3dfbd90d1d Mon Sep 17 00:00:00 2001 From: Greg Lange <glange@rackspace.com> Date: Wed, 12 Jan 2011 21:09:39 +0000 Subject: [PATCH] Made older functional tests look for default config file when env variable is unset --- test/functional/swift.py | 5 +++++ test/functional/tests.py | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/functional/swift.py b/test/functional/swift.py index f7d580b93d..b251bcc047 100644 --- a/test/functional/swift.py +++ b/test/functional/swift.py @@ -24,6 +24,7 @@ import urllib import simplejson as json +from nose import SkipTest from xml.dom import minidom class AuthenticationFailed(Exception): @@ -79,6 +80,10 @@ def listing_items(method): class Connection(object): def __init__(self, config): + for key in 'auth_host auth_port auth_ssl account username password'.split(): + if not config.has_key(key): + raise SkipTest + self.auth_host = config['auth_host'] self.auth_port = int(config['auth_port']) self.auth_ssl = config['auth_ssl'] in ('on', 'true', 'yes', '1') diff --git a/test/functional/tests.py b/test/functional/tests.py index 4cf090ae5d..482b507b52 100644 --- a/test/functional/tests.py +++ b/test/functional/tests.py @@ -19,8 +19,10 @@ import configobj from datetime import datetime import locale import os +import os.path import random import StringIO +import sys import time import threading import uuid @@ -30,10 +32,18 @@ import urllib from swift import Account, AuthenticationFailed, Connection, Container, \ File, ResponseError -config = configobj.ConfigObj(os.environ['SWIFT_TEST_CONFIG_FILE']) -locale.setlocale(locale.LC_COLLATE, config.get('collate', 'C')) +config_file_env_var = 'SWIFT_TEST_CONFIG_FILE' +default_config_file = '/etc/swift/func_test.conf' -NoRun = object +if os.environ.has_key(config_file_env_var): + config_file = os.environ[config_file_env_var] +elif os.path.isfile(default_config_file): + config_file = default_config_file +else: + print >>sys.stderr, 'SKIPPING FUNCTIONAL TESTS DUE TO NO CONFIG' + +config = configobj.ConfigObj(config_file) +locale.setlocale(locale.LC_COLLATE, config.get('collate', 'C')) class Base: pass