| 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_gsconnection import GSConnectionTest | |
| 36 from s3.test_https_cert_validation import CertValidationTest | |
| 37 from ec2.test_connection import EC2ConnectionTest | |
| 38 from autoscale.test_connection import AutoscaleConnectionTest | |
| 39 from sdb.test_connection import SDBConnectionTest | |
| 40 | |
| 41 def usage(): | |
| 42 print "test.py [-t testsuite] [-v verbosity]" | |
| 43 print " -t run specific testsuite (s3|ssl|s3ver|s3nover|gs|sqs|ec2|sdb|
all)" | |
| 44 print " -v verbosity (0|1|2)" | |
| 45 | |
| 46 def main(): | |
| 47 try: | |
| 48 opts, args = getopt.getopt(sys.argv[1:], "ht:v:", | |
| 49 ["help", "testsuite", "verbosity"]) | |
| 50 except: | |
| 51 usage() | |
| 52 sys.exit(2) | |
| 53 testsuite = "all" | |
| 54 verbosity = 1 | |
| 55 for o, a in opts: | |
| 56 if o in ("-h", "--help"): | |
| 57 usage() | |
| 58 sys.exit() | |
| 59 if o in ("-t", "--testsuite"): | |
| 60 testsuite = a | |
| 61 if o in ("-v", "--verbosity"): | |
| 62 verbosity = int(a) | |
| 63 if len(args) != 0: | |
| 64 usage() | |
| 65 sys.exit() | |
| 66 try: | |
| 67 tests = suite(testsuite) | |
| 68 except ValueError: | |
| 69 usage() | |
| 70 sys.exit() | |
| 71 if verbosity > 1: | |
| 72 logging.basicConfig(level=logging.DEBUG) | |
| 73 unittest.TextTestRunner(verbosity=verbosity).run(tests) | |
| 74 | |
| 75 def suite(testsuite="all"): | |
| 76 tests = unittest.TestSuite() | |
| 77 if testsuite == "all": | |
| 78 tests.addTest(unittest.makeSuite(SQSConnectionTest)) | |
| 79 tests.addTest(unittest.makeSuite(S3ConnectionTest)) | |
| 80 tests.addTest(unittest.makeSuite(EC2ConnectionTest)) | |
| 81 tests.addTest(unittest.makeSuite(SDBConnectionTest)) | |
| 82 tests.addTest(unittest.makeSuite(AutoscaleConnectionTest)) | |
| 83 elif testsuite == "s3": | |
| 84 tests.addTest(unittest.makeSuite(S3ConnectionTest)) | |
| 85 tests.addTest(unittest.makeSuite(S3VersionTest)) | |
| 86 elif testsuite == "ssl": | |
| 87 tests.addTest(unittest.makeSuite(CertValidationTest)) | |
| 88 elif testsuite == "s3ver": | |
| 89 tests.addTest(unittest.makeSuite(S3VersionTest)) | |
| 90 elif testsuite == "s3nover": | |
| 91 tests.addTest(unittest.makeSuite(S3ConnectionTest)) | |
| 92 elif testsuite == "gs": | |
| 93 tests.addTest(unittest.makeSuite(GSConnectionTest)) | |
| 94 elif testsuite == "sqs": | |
| 95 tests.addTest(unittest.makeSuite(SQSConnectionTest)) | |
| 96 elif testsuite == "ec2": | |
| 97 tests.addTest(unittest.makeSuite(EC2ConnectionTest)) | |
| 98 elif testsuite == "autoscale": | |
| 99 tests.addTest(unittest.makeSuite(AutoscaleConnectionTest)) | |
| 100 elif testsuite == "sdb": | |
| 101 tests.addTest(unittest.makeSuite(SDBConnectionTest)) | |
| 102 else: | |
| 103 raise ValueError("Invalid choice.") | |
| 104 return tests | |
| 105 | |
| 106 if __name__ == "__main__": | |
| 107 main() | |
| OLD | NEW |