Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1050)

Unified Diff: third_party/gsutil/boto/tests/fps/test.py

Issue 12042069: Scripts to download files from google storage based on sha1 sums (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Review fixes, updated gsutil Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/gsutil/boto/tests/fps/test.py
diff --git a/third_party/gsutil/boto/tests/fps/test.py b/third_party/gsutil/boto/tests/fps/test.py
new file mode 100755
index 0000000000000000000000000000000000000000..d5efb4b75c496850c05b7e4f3c4683b194445fd1
--- /dev/null
+++ b/third_party/gsutil/boto/tests/fps/test.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+
+from tests.unit import unittest
+import sys
+import os
+import os.path
+
+simple = True
+advanced = False
+if __name__ == "__main__":
+ devpath = os.path.relpath(os.path.join('..', '..'),
+ start=os.path.dirname(__file__))
+ sys.path = [devpath] + sys.path
+ print '>>> advanced FPS tests; using local boto sources'
+ advanced = True
+
+from boto.fps.connection import FPSConnection
+from boto.fps.response import ComplexAmount
+
+
+class FPSTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.fps = FPSConnection(host='fps.sandbox.amazonaws.com')
+ if advanced:
+ self.activity = self.fps.get_account_activity(\
+ StartDate='2012-01-01')
+ result = self.activity.GetAccountActivityResult
+ self.transactions = result.Transaction
+
+ @unittest.skipUnless(simple, "skipping simple test")
+ def test_get_account_balance(self):
+ response = self.fps.get_account_balance()
+ self.assertTrue(hasattr(response, 'GetAccountBalanceResult'))
+ self.assertTrue(hasattr(response.GetAccountBalanceResult,
+ 'AccountBalance'))
+ accountbalance = response.GetAccountBalanceResult.AccountBalance
+ self.assertTrue(hasattr(accountbalance, 'TotalBalance'))
+ self.assertIsInstance(accountbalance.TotalBalance, ComplexAmount)
+ self.assertTrue(hasattr(accountbalance, 'AvailableBalances'))
+ availablebalances = accountbalance.AvailableBalances
+ self.assertTrue(hasattr(availablebalances, 'RefundBalance'))
+
+ @unittest.skipUnless(simple, "skipping simple test")
+ def test_complex_amount(self):
+ response = self.fps.get_account_balance()
+ accountbalance = response.GetAccountBalanceResult.AccountBalance
+ asfloat = float(accountbalance.TotalBalance.Value)
+ self.assertIn('.', str(asfloat))
+
+ @unittest.skipUnless(simple, "skipping simple test")
+ def test_required_arguments(self):
+ with self.assertRaises(KeyError):
+ self.fps.write_off_debt(AdjustmentAmount=123.45)
+
+ @unittest.skipUnless(simple, "skipping simple test")
+ def test_cbui_url(self):
+ inputs = {
+ 'transactionAmount': 123.45,
+ 'pipelineName': 'SingleUse',
+ 'returnURL': 'https://localhost/',
+ 'paymentReason': 'a reason for payment',
+ 'callerReference': 'foo',
+ }
+ result = self.fps.cbui_url(**inputs)
+ print "cbui_url() yields {0}".format(result)
+
+ @unittest.skipUnless(simple, "skipping simple test")
+ def test_get_account_activity(self):
+ response = self.fps.get_account_activity(StartDate='2012-01-01')
+ self.assertTrue(hasattr(response, 'GetAccountActivityResult'))
+ result = response.GetAccountActivityResult
+ self.assertTrue(hasattr(result, 'BatchSize'))
+ try:
+ int(result.BatchSize)
+ except:
+ self.assertTrue(False)
+
+ @unittest.skipUnless(advanced, "skipping advanced test")
+ def test_get_transaction(self):
+ assert len(self.transactions)
+ transactionid = self.transactions[0].TransactionId
+ result = self.fps.get_transaction(TransactionId=transactionid)
+ self.assertTrue(hasattr(result.GetTransactionResult, 'Transaction'))
+
+ @unittest.skip('cosmetic')
+ def test_bad_request(self):
+ try:
+ self.fps.write_off_debt(CreditInstrumentId='foo',
+ AdjustmentAmount=123.45)
+ except Exception, e:
+ print e
+
+ @unittest.skip('cosmetic')
+ def test_repr(self):
+ print self.fps.get_account_balance()
+
+
+if __name__ == "__main__":
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698