OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 try: |
| 3 from tests.unit import unittest |
| 4 except ImportError: |
| 5 import unittest |
| 6 import sys |
| 7 import os |
| 8 import os.path |
| 9 |
| 10 |
| 11 simple = os.environ.get('MWS_MERCHANT', None) |
| 12 if not simple: |
| 13 print """ |
| 14 Please set the MWS_MERCHANT environmental variable |
| 15 to your Merchant or SellerId to enable MWS tests. |
| 16 """ |
| 17 |
| 18 |
| 19 advanced = False |
| 20 isolator = True |
| 21 if __name__ == "__main__": |
| 22 devpath = os.path.relpath(os.path.join('..', '..'), |
| 23 start=os.path.dirname(__file__)) |
| 24 sys.path = [devpath] + sys.path |
| 25 advanced = simple and True or False |
| 26 if advanced: |
| 27 print '>>> advanced MWS tests; using local boto sources' |
| 28 |
| 29 from boto.mws.connection import MWSConnection |
| 30 |
| 31 |
| 32 class MWSTestCase(unittest.TestCase): |
| 33 |
| 34 def setUp(self): |
| 35 self.mws = MWSConnection(Merchant=simple, debug=0) |
| 36 |
| 37 @unittest.skipUnless(simple and isolator, "skipping simple test") |
| 38 def test_feedlist(self): |
| 39 self.mws.get_feed_submission_list() |
| 40 |
| 41 @unittest.skipUnless(simple and isolator, "skipping simple test") |
| 42 def test_inbound_status(self): |
| 43 response = self.mws.get_inbound_service_status() |
| 44 status = response.GetServiceStatusResult.Status |
| 45 self.assertIn(status, ('GREEN', 'GREEN_I', 'YELLOW', 'RED')) |
| 46 |
| 47 @property |
| 48 def marketplace(self): |
| 49 response = self.mws.list_marketplace_participations() |
| 50 result = response.ListMarketplaceParticipationsResult |
| 51 return result.ListMarketplaces.Marketplace[0] |
| 52 |
| 53 @property |
| 54 def marketplace_id(self): |
| 55 return self.marketplace.MarketplaceId |
| 56 |
| 57 @unittest.skipUnless(simple and isolator, "skipping simple test") |
| 58 def test_marketplace_participations(self): |
| 59 response = self.mws.list_marketplace_participations() |
| 60 result = response.ListMarketplaceParticipationsResult |
| 61 self.assertTrue(result.ListMarketplaces.Marketplace[0].MarketplaceId) |
| 62 |
| 63 @unittest.skipUnless(simple and isolator, "skipping simple test") |
| 64 def test_get_product_categories_for_asin(self): |
| 65 asin = '144930544X' |
| 66 response = self.mws.get_product_categories_for_asin(\ |
| 67 MarketplaceId=self.marketplace_id, |
| 68 ASIN=asin) |
| 69 result = response._result |
| 70 self.assertTrue(int(result.Self.ProductCategoryId) == 21) |
| 71 |
| 72 @unittest.skipUnless(simple and isolator, "skipping simple test") |
| 73 def test_list_matching_products(self): |
| 74 response = self.mws.list_matching_products(\ |
| 75 MarketplaceId=self.marketplace_id, |
| 76 Query='boto') |
| 77 products = response._result.Products |
| 78 self.assertTrue(len(products)) |
| 79 |
| 80 @unittest.skipUnless(simple and isolator, "skipping simple test") |
| 81 def test_get_matching_product(self): |
| 82 asin = 'B001UDRNHO' |
| 83 response = self.mws.get_matching_product(\ |
| 84 MarketplaceId=self.marketplace_id, |
| 85 ASINList=[asin,]) |
| 86 product = response._result[0].Product |
| 87 |
| 88 |
| 89 @unittest.skipUnless(simple and isolator, "skipping simple test") |
| 90 def test_get_lowest_offer_listings_for_asin(self): |
| 91 asin = '144930544X' |
| 92 response = self.mws.get_lowest_offer_listings_for_asin(\ |
| 93 MarketplaceId=self.marketplace_id, |
| 94 ItemCondition='New', |
| 95 ASINList=[asin,]) |
| 96 product = response._result[0].Product |
| 97 self.assertTrue(product.LowestOfferListings) |
| 98 |
| 99 if __name__ == "__main__": |
| 100 unittest.main() |
OLD | NEW |