20
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
32
from sqs.test_connection import SQSConnectionTest
33
from s3.test_connection import S3ConnectionTest
34
from s3.test_versioning import S3VersionTest
35
from s3.test_mfa import S3MFATest
36
from s3.test_encryption import S3EncryptionTest
37
from s3.test_bucket import S3BucketTest
38
from s3.test_key import S3KeyTest
39
from s3.test_multidelete import S3MultiDeleteTest
40
from s3.test_multipart import S3MultiPartUploadTest
41
from s3.test_gsconnection import GSConnectionTest
42
from s3.test_https_cert_validation import CertValidationTest
43
from ec2.test_connection import EC2ConnectionTest
44
from ec2.elb.test_connection import ELBConnectionTest
45
from ec2.cloudwatch.test_connection import CloudWatchConnectionTest
46
from autoscale.test_connection import AutoscaleConnectionTest
47
from sdb.test_connection import SDBConnectionTest
48
from cloudfront.test_signed_urls import CloudfrontSignedUrlsTest
49
from dynamodb.test_layer1 import DynamoDBLayer1Test
50
from dynamodb.test_layer2 import DynamoDBLayer2Test
51
from sts.test_session_token import SessionTokenTest
54
print "test.py [-t testsuite] [-v verbosity]"
55
print " -t run specific testsuite (s3|ssl|s3mfa|gs|sqs|ec2|sdb|dynamodb|dynamodbL1|dynamodbL2|sts|all)"
56
print " -v verbosity (0|1|2)"
27
from nose.core import run
60
opts, args = getopt.getopt(sys.argv[1:], "ht:v:",
61
["help", "testsuite", "verbosity"])
68
if o in ("-h", "--help"):
71
if o in ("-t", "--testsuite"):
73
if o in ("-v", "--verbosity"):
79
tests = suite(testsuite)
84
logging.basicConfig(level=logging.DEBUG)
85
unittest.TextTestRunner(verbosity=verbosity).run(tests)
87
def suite(testsuite="all"):
88
tests = unittest.TestSuite()
89
if testsuite == "all":
90
tests.addTest(unittest.makeSuite(SQSConnectionTest))
91
tests.addTest(unittest.makeSuite(S3ConnectionTest))
92
tests.addTest(unittest.makeSuite(EC2ConnectionTest))
93
tests.addTest(unittest.makeSuite(SDBConnectionTest))
94
tests.addTest(unittest.makeSuite(AutoscaleConnectionTest))
95
tests.addTest(unittest.makeSuite(CloudfrontSignedUrlsTest))
96
tests.addTest(unittest.makeSuite(DynamoDBLayer1Test))
97
tests.addTest(unittest.makeSuite(DynamoDBLayer2Test))
98
elif testsuite == "s3":
99
tests.addTest(unittest.makeSuite(S3ConnectionTest))
100
tests.addTest(unittest.makeSuite(S3BucketTest))
101
tests.addTest(unittest.makeSuite(S3KeyTest))
102
tests.addTest(unittest.makeSuite(S3MultiPartUploadTest))
103
tests.addTest(unittest.makeSuite(S3VersionTest))
104
tests.addTest(unittest.makeSuite(S3EncryptionTest))
105
tests.addTest(unittest.makeSuite(S3MultiDeleteTest))
106
elif testsuite == "ssl":
107
tests.addTest(unittest.makeSuite(CertValidationTest))
108
elif testsuite == "s3mfa":
109
tests.addTest(unittest.makeSuite(S3MFATest))
110
elif testsuite == "gs":
111
tests.addTest(unittest.makeSuite(GSConnectionTest))
112
elif testsuite == "sqs":
113
tests.addTest(unittest.makeSuite(SQSConnectionTest))
114
elif testsuite == "ec2":
115
tests.addTest(unittest.makeSuite(EC2ConnectionTest))
116
tests.addTest(unittest.makeSuite(AutoscaleConnectionTest))
117
tests.addTest(unittest.makeSuite(ELBConnectionTest))
118
tests.addTest(unittest.makeSuite(CloudWatchConnectionTest))
119
elif testsuite == "autoscale":
120
tests.addTest(unittest.makeSuite(AutoscaleConnectionTest))
121
elif testsuite == "sdb":
122
tests.addTest(unittest.makeSuite(SDBConnectionTest))
123
elif testsuite == "cloudfront":
124
tests.addTest(unittest.makeSuite(CloudfrontSignedUrlsTest))
125
elif testsuite == "dynamodb":
126
tests.addTest(unittest.makeSuite(DynamoDBLayer1Test))
127
tests.addTest(unittest.makeSuite(DynamoDBLayer2Test))
128
elif testsuite == "dynamodbL1":
129
tests.addTest(unittest.makeSuite(DynamoDBLayer1Test))
130
elif testsuite == "dynamodbL2":
131
tests.addTest(unittest.makeSuite(DynamoDBLayer2Test))
132
elif testsuite == "sts":
133
tests.addTest(unittest.makeSuite(SessionTokenTest))
32
description = ("Runs boto unit and/or integration tests. "
33
"Arguments will be passed on to nosetests. "
34
"See nosetests --help for more information.")
35
parser = argparse.ArgumentParser(description=description)
36
parser.add_argument('-t', '--service-tests', action="append", default=[],
37
help="Run tests for a given service. This will "
38
"run any test tagged with the specified value, "
40
known_args, remaining_args = parser.parse_known_args()
42
for service_attribute in known_args.service_tests:
43
attribute_args.extend(['-a', '!notdefault,' +service_attribute])
44
if not attribute_args:
45
# If the user did not specify any filtering criteria, we at least
46
# will filter out any test tagged 'notdefault'.
47
attribute_args = ['-a', '!notdefault']
48
all_args = [__file__] + attribute_args + remaining_args
49
print "nose command:", ' '.join(all_args)
50
if run(argv=all_args):
51
# run will return True is all the tests pass. We want
52
# this to equal a 0 rc
135
raise ValueError("Invalid choice.")
138
58
if __name__ == "__main__":