]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
add calling_format switch in functional and common
authorMatthew Wodrich <matthew.wodrich@dreamhost.com>
Thu, 3 Nov 2011 17:22:23 +0000 (10:22 -0700)
committerMatthew Wodrich <matthew.wodrich@dreamhost.com>
Thu, 3 Nov 2011 17:22:23 +0000 (10:22 -0700)
Add calling_format switch with options ordinary, subdomain, and vhost to
s3tests/functional/__init__.py and /s3tests/common.py to allow the use
of OrdinaryCallingFormat, SubdomainCallingFormat, and VHostCallingFormat
in the config files for the nosetests and the tools using the common
parser.

s3tests/common.py
s3tests/functional/__init__.py

index 1148bbaec16c9c3d7cce3d711da9b60ef9b1c942..b096cdc2bc061009c509d29bf9a23d4575359669 100644 (file)
@@ -93,11 +93,23 @@ def connect(conf):
         secret_key='aws_secret_access_key',
         )
     kwargs = dict((mapping[k],v) for (k,v) in conf.iteritems() if k in mapping)
-    conn = boto.s3.connection.S3Connection(
-        # TODO support & test all variations
-        calling_format=boto.s3.connection.OrdinaryCallingFormat(),
-        **kwargs
+    #process calling_format argument
+    calling_formats = dict(
+        ordinary=boto.s3.connection.OrdinaryCallingFormat(),
+        subdomain=boto.s3.connection.SubdomainCallingFormat(),
+        vhost=boto.s3.connection.VHostCallingFormat(),
         )
+    kwargs['calling_format'] = calling_formats['ordinary']
+    if conf.has_key('calling_format'):
+        raw_calling_format = conf['calling_format']
+        try:
+            kwargs['calling_format'] = calling_formats[raw_calling_format]
+        except KeyError:
+            raise RuntimeError(
+                'calling_format unknown: %r' % raw_calling_format
+                )
+    # TODO test vhost calling format
+    conn = boto.s3.connection.S3Connection(**kwargs)
     return conn
 
 def setup():
index 2b25d821248540b213c5325256ba188d10142791..1e92c09895bf0eeaf7add7f85b6233fea796cbc1 100644 (file)
@@ -96,6 +96,11 @@ def setup():
 
     s3.clear()
     config.clear()
+    calling_formats = dict(
+        ordinary=boto.s3.connection.OrdinaryCallingFormat(),
+        subdomain=boto.s3.connection.SubdomainCallingFormat(),
+        vhost=boto.s3.connection.VHostCallingFormat(),
+        )
     for section in cfg.sections():
         try:
             (type_, name) = section.split(None, 1)
@@ -108,6 +113,18 @@ def setup():
         except ConfigParser.NoOptionError:
             port = None
 
+        try:
+            raw_calling_format = cfg.get(section, 'calling_format')
+        except ConfigParser.NoOptionError:
+            raw_calling_format = 'ordinary'
+
+        try:
+            calling_format = calling_formats[raw_calling_format]
+        except KeyError:
+            raise RuntimeError(
+                'calling_format unknown: %r' % raw_calling_format
+                )
+
         config[name] = bunch.Bunch()
         for var in [
             'user_id',
@@ -124,8 +141,8 @@ def setup():
             is_secure=cfg.getboolean(section, 'is_secure'),
             port=port,
             host=cfg.get(section, 'host'),
-            # TODO support & test all variations
-            calling_format=boto.s3.connection.OrdinaryCallingFormat(),
+            # TODO test vhost calling format
+            calling_format=calling_format,
             )
         s3[name] = conn