~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/boto/boto/tests/test.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# Copyright (c) 2006,2007 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 sys, os, unittest
 
28
import getopt, sys
 
29
import boto
 
30
 
 
31
from boto.tests.test_sqsconnection import SQSConnectionTest
 
32
from boto.tests.test_s3connection import S3ConnectionTest
 
33
from boto.tests.test_s3versioning import S3VersionTest
 
34
from boto.tests.test_ec2connection import EC2ConnectionTest
 
35
from boto.tests.test_sdbconnection import SDBConnectionTest
 
36
 
 
37
def usage():
 
38
    print 'test.py  [-t testsuite] [-v verbosity]'
 
39
    print '    -t   run specific testsuite (s3|sqs|ec2|sdb|all)'
 
40
    print '    -v   verbosity (0|1|2)'
 
41
  
 
42
def main():
 
43
    try:
 
44
        opts, args = getopt.getopt(sys.argv[1:], 'ht:v:',
 
45
                                   ['help', 'testsuite', 'verbosity'])
 
46
    except:
 
47
        usage()
 
48
        sys.exit(2)
 
49
    testsuite = 'all'
 
50
    verbosity = 1
 
51
    for o, a in opts:
 
52
        if o in ('-h', '--help'):
 
53
            usage()
 
54
            sys.exit()
 
55
        if o in ('-t', '--testsuite'):
 
56
            testsuite = a
 
57
        if o in ('-v', '--verbosity'):
 
58
            verbosity = int(a)
 
59
    if len(args) != 0:
 
60
        usage()
 
61
        sys.exit()
 
62
    suite = unittest.TestSuite()
 
63
    if testsuite == 'all':
 
64
        suite.addTest(unittest.makeSuite(SQSConnectionTest))
 
65
        suite.addTest(unittest.makeSuite(S3ConnectionTest))
 
66
        suite.addTest(unittest.makeSuite(EC2ConnectionTest))
 
67
        suite.addTest(unittest.makeSuite(SDBConnectionTest))
 
68
    elif testsuite == 's3':
 
69
        suite.addTest(unittest.makeSuite(S3ConnectionTest))
 
70
        suite.addTest(unittest.makeSuite(S3VersionTest))
 
71
    elif testsuite == 's3ver':
 
72
        suite.addTest(unittest.makeSuite(S3VersionTest))
 
73
    elif testsuite == 'sqs':
 
74
        suite.addTest(unittest.makeSuite(SQSConnectionTest))
 
75
    elif testsuite == 'ec2':
 
76
        suite.addTest(unittest.makeSuite(EC2ConnectionTest))
 
77
    elif testsuite == 'sdb':
 
78
        suite.addTest(unittest.makeSuite(SDBConnectionTest))
 
79
    else:
 
80
        usage()
 
81
        sys.exit()
 
82
    unittest.TextTestRunner(verbosity=verbosity).run(suite)
 
83
 
 
84
if __name__ == "__main__":
 
85
    main()