Made older functional tests look for default config file when env variable is unset

This commit is contained in:
Greg Lange 2011-01-12 21:09:39 +00:00
parent 2962557612
commit e5c5a3778e
2 changed files with 18 additions and 3 deletions

View File

@ -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')

View File

@ -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