OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2006-2011 Mitch Garnaat http://garnaat.org/ |
| 3 # |
| 4 # Permission is hereby granted, free of charge, to any person obtaining a |
| 5 # copy of this software and associated documentation files (the |
| 6 # "Software"), to deal in the Software without restriction, including |
| 7 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 8 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 9 # persons to whom the Software is furnished to do so, subject to the fol- |
| 10 # lowing conditions: |
| 11 # |
| 12 # The above copyright notice and this permission notice shall be included |
| 13 # in all copies or substantial portions of the Software. |
| 14 # |
| 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
| 17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
| 18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 21 # IN THE SOFTWARE. |
| 22 |
| 23 """ |
| 24 do the unit tests! |
| 25 """ |
| 26 |
| 27 import logging |
| 28 import sys |
| 29 import unittest |
| 30 import getopt |
| 31 |
| 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_encryption import S3EncryptionTest |
| 36 from s3.test_gsconnection import GSConnectionTest |
| 37 from s3.test_https_cert_validation import CertValidationTest |
| 38 from ec2.test_connection import EC2ConnectionTest |
| 39 from autoscale.test_connection import AutoscaleConnectionTest |
| 40 from sdb.test_connection import SDBConnectionTest |
| 41 from cloudfront.test_signed_urls import CloudfrontSignedUrlsTest |
| 42 |
| 43 def usage(): |
| 44 print "test.py [-t testsuite] [-v verbosity]" |
| 45 print " -t run specific testsuite (s3|ssl|s3ver|s3nover|gs|sqs|ec2|sdb|
all)" |
| 46 print " -v verbosity (0|1|2)" |
| 47 |
| 48 def main(): |
| 49 try: |
| 50 opts, args = getopt.getopt(sys.argv[1:], "ht:v:", |
| 51 ["help", "testsuite", "verbosity"]) |
| 52 except: |
| 53 usage() |
| 54 sys.exit(2) |
| 55 testsuite = "all" |
| 56 verbosity = 1 |
| 57 for o, a in opts: |
| 58 if o in ("-h", "--help"): |
| 59 usage() |
| 60 sys.exit() |
| 61 if o in ("-t", "--testsuite"): |
| 62 testsuite = a |
| 63 if o in ("-v", "--verbosity"): |
| 64 verbosity = int(a) |
| 65 if len(args) != 0: |
| 66 usage() |
| 67 sys.exit() |
| 68 try: |
| 69 tests = suite(testsuite) |
| 70 except ValueError: |
| 71 usage() |
| 72 sys.exit() |
| 73 if verbosity > 1: |
| 74 logging.basicConfig(level=logging.DEBUG) |
| 75 unittest.TextTestRunner(verbosity=verbosity).run(tests) |
| 76 |
| 77 def suite(testsuite="all"): |
| 78 tests = unittest.TestSuite() |
| 79 if testsuite == "all": |
| 80 tests.addTest(unittest.makeSuite(SQSConnectionTest)) |
| 81 tests.addTest(unittest.makeSuite(S3ConnectionTest)) |
| 82 tests.addTest(unittest.makeSuite(EC2ConnectionTest)) |
| 83 tests.addTest(unittest.makeSuite(SDBConnectionTest)) |
| 84 tests.addTest(unittest.makeSuite(AutoscaleConnectionTest)) |
| 85 tests.addTest(unittest.makeSuite(CloudfrontSignedUrlsTest)) |
| 86 elif testsuite == "s3": |
| 87 tests.addTest(unittest.makeSuite(S3ConnectionTest)) |
| 88 tests.addTest(unittest.makeSuite(S3VersionTest)) |
| 89 tests.addTest(unittest.makeSuite(S3EncryptionTest)) |
| 90 elif testsuite == "ssl": |
| 91 tests.addTest(unittest.makeSuite(CertValidationTest)) |
| 92 elif testsuite == "s3ver": |
| 93 tests.addTest(unittest.makeSuite(S3VersionTest)) |
| 94 elif testsuite == "s3nover": |
| 95 tests.addTest(unittest.makeSuite(S3ConnectionTest)) |
| 96 tests.addTest(unittest.makeSuite(S3EncryptionTest)) |
| 97 elif testsuite == "gs": |
| 98 tests.addTest(unittest.makeSuite(GSConnectionTest)) |
| 99 elif testsuite == "sqs": |
| 100 tests.addTest(unittest.makeSuite(SQSConnectionTest)) |
| 101 elif testsuite == "ec2": |
| 102 tests.addTest(unittest.makeSuite(EC2ConnectionTest)) |
| 103 elif testsuite == "autoscale": |
| 104 tests.addTest(unittest.makeSuite(AutoscaleConnectionTest)) |
| 105 elif testsuite == "sdb": |
| 106 tests.addTest(unittest.makeSuite(SDBConnectionTest)) |
| 107 elif testsuite == "cloudfront": |
| 108 tests.addTest(unittest.makeSuite(CloudfrontSignedUrlsTest)) |
| 109 else: |
| 110 raise ValueError("Invalid choice.") |
| 111 return tests |
| 112 |
| 113 if __name__ == "__main__": |
| 114 main() |
OLD | NEW |