00001
00002
00003
00004
00005
00006
00007 import sys, unittest, time
00008 from ServiceTest import main, ServiceTestCase, ServiceTestSuite, TestException
00009 from ZSI.schema import ElementDeclaration, GED
00010 from ZSI import ParsedSoap
00011
00012 """
00013 Unittest for contacting the Amazon ECommerce Service
00014
00015 WSDL:
00016
00017 """
00018
00019 def dispatch():
00020 """Run all dispatch tests"""
00021 suite = ServiceTestSuite()
00022 suite.addTest(unittest.makeSuite(AmazonTestCase, 'test_dispatch'))
00023 return suite
00024
00025 def local():
00026 """Run all local tests"""
00027 suite = ServiceTestSuite()
00028 suite.addTest(unittest.makeSuite(AmazonTestCase, 'test_local'))
00029 return suite
00030
00031 def net():
00032 """Run all network tests"""
00033 suite = ServiceTestSuite()
00034 suite.addTest(unittest.makeSuite(AmazonTestCase, 'test_net'))
00035 return suite
00036
00037 def all():
00038 """Run all tests"""
00039 suite = ServiceTestSuite()
00040 suite.addTest(unittest.makeSuite(AmazonTestCase, 'test_'))
00041 return suite
00042
00043
00044 class AmazonTestCase(ServiceTestCase):
00045 """Test case for AmazonS3 web service
00046 """
00047 name = "test_AmazonS3"
00048 client_file_name = "AmazonS3_client.py"
00049 types_file_name = "AmazonS3_types.py"
00050 server_file_name = "AmazonS3_server.py"
00051
00052 def __init__(self, methodName):
00053 ServiceTestCase.__init__(self, methodName)
00054 self.wsdl2py_args.append('-b')
00055 self.wsdl2py_args.append('--lazy')
00056
00057 def test_local_import(self):
00058 pass
00059
00060 def test_net_CreateBucket(self):
00061 loc = self.client_module.AmazonS3Locator()
00062 port = loc.getAmazonS3(**self.getPortKWArgs())
00063
00064 msg = self.client_module.CreateBucketRequest()
00065
00066 msg.Bucket = "HoneyPot"
00067 acl = msg.AccessControlList = msg.new_AccessControlList()
00068 grant = acl.new_Grant()
00069 acl.Grant = [grant]
00070 grant.Grantee = grant.new_Grantee()
00071 grant.Permission = grant.new_Permission("YES")
00072
00073 msg.AWSAccessKeyId = '0HP1WHME000749APYWR2'
00074 msg.Timestamp = time.gmtime()
00075 msg.Signature = 'whatever'
00076
00077 rsp = port.CreateBucket(msg)
00078
00079
00080
00081 if __name__ == '__main__':
00082 main()