diff options
author | Mitch Garnaat <mitch@garnaat.com> | 2012-05-15 18:59:46 -0700 |
---|---|---|
committer | Mitch Garnaat <mitch@garnaat.com> | 2012-05-15 18:59:46 -0700 |
commit | 1aa1133e8502ea6c95e49ac34681569df5ace46b (patch) | |
tree | a25397b20d7d409131ccfbfce5d4dca23d7e52a4 /tests/mws/test.py | |
parent | 911f42b97fdccbc55e160ec323df0cad6fe64c6b (diff) | |
parent | 6588ea270bfc9e0bb4d17263b72ee8b5255545c5 (diff) | |
download | boto-2.4.0.tar.gz |
Merge branch 'release-2.4.0'2.4.0
Diffstat (limited to 'tests/mws/test.py')
-rwxr-xr-x | tests/mws/test.py | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/mws/test.py b/tests/mws/test.py new file mode 100755 index 00000000..e1448fe4 --- /dev/null +++ b/tests/mws/test.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +from unittest import main, skip, skipUnless, TestCase +import sys +import os +import os.path + + +simple = os.environ.get('MWS_MERCHANT', None) +if not simple: + print """ + Please set the MWS_MERCHANT environmental variable + to your Merchant or SellerId to enable MWS tests. + """ + + +advanced = False +isolator = True +if __name__ == "__main__": + devpath = os.path.relpath(os.path.join('..', '..'), + start=os.path.dirname(__file__)) + sys.path = [devpath] + sys.path + advanced = simple and True or False + if advanced: + print '>>> advanced MWS tests; using local boto sources' + +from boto.mws.connection import MWSConnection + + +class MWSTestCase(TestCase): + + def __init__(self, *args, **kw): + TestCase.__init__(self, *args, **kw) + self.mws = MWSConnection(Merchant=simple, debug=0) + + @skipUnless(simple and isolator, "skipping simple test") + def test_feedlist(self): + self.mws.get_feed_submission_list() + + @skipUnless(simple and isolator, "skipping simple test") + def test_inbound_status(self): + response = self.mws.get_inbound_service_status() + status = response.GetServiceStatusResult.Status + self.assertIn(status, ('GREEN', 'GREEN_I', 'YELLOW', 'RED')) + + @property + def marketplace(self): + response = self.mws.list_marketplace_participations() + result = response.ListMarketplaceParticipationsResult + return result.ListMarketplaces.Marketplace[0] + + @property + def marketplace_id(self): + return self.marketplace.MarketplaceId + + @skipUnless(simple and isolator, "skipping simple test") + def test_marketplace_participations(self): + response = self.mws.list_marketplace_participations() + result = response.ListMarketplaceParticipationsResult + self.assertTrue(result.ListMarketplaces.Marketplace[0].MarketplaceId) + + @skipUnless(simple and isolator, "skipping simple test") + def test_get_product_categories_for_asin(self): + asin = '144930544X' + response = self.mws.get_product_categories_for_asin(\ + MarketplaceId=self.marketplace_id, + ASIN=asin) + result = response._result + self.assertTrue(int(result.Self.ProductCategoryId) == 21) + + @skipUnless(simple and isolator, "skipping simple test") + def test_list_matching_products(self): + response = self.mws.list_matching_products(\ + MarketplaceId=self.marketplace_id, + Query='boto') + products = response._result.Products + self.assertTrue(len(products)) + + @skipUnless(simple and isolator, "skipping simple test") + def test_get_matching_product(self): + asin = 'B001UDRNHO' + response = self.mws.get_matching_product(\ + MarketplaceId=self.marketplace_id, + ASINList=[asin,]) + product = response._result[0].Product + + + @skipUnless(simple and isolator, "skipping simple test") + def test_get_lowest_offer_listings_for_asin(self): + asin = '144930544X' + response = self.mws.get_lowest_offer_listings_for_asin(\ + MarketplaceId=self.marketplace_id, + ItemCondition='New', + ASINList=[asin,]) + product = response._result[0].Product + self.assertTrue(product.LowestOfferListings) + +if __name__ == "__main__": + main() |